/// <summary> /// 创建进度圆环的各个叶瓣的轮廓线 /// </summary> /// <param name="pivot">进度圆环的几何中心坐标</param> /// <param name="outterRadius">进度圆环的外边界半径</param> /// <param name="innerRadius">进度圆环的内边界半径</param> /// <param name="spokes">进度圆环的叶瓣数量</param> /// <param name="angleOffset">X轴顶角坐标偏移度数</param> /// <returns>组成进度圆环的各个叶瓣的轮廓线坐标链表</returns> public static List <PointF[]> CreateWaitCircleSpokes(PointF pivot, float outterRadius, float innerRadius, int spokes, float angleOffset) { if (spokes < 1) { throw new ArgumentException("参数spokes必须大于等于1。"); } List <PointF[]> lst = new List <PointF[]>(); CircleF outter = new CircleF(pivot, outterRadius); CircleF inner = new CircleF(pivot, innerRadius); float ang = 360.0f / spokes; for (int i = 0; i < spokes; i++) { lst.Add(new PointF[2] { outter.PointOnPath(angleOffset + i * ang), inner.PointOnPath(angleOffset + i * ang) }); } return(lst); }
/// <summary> /// 创建正多边形的顶点数组。 /// </summary> /// <param name="pivot">正多边形的几何中心坐标。</param> /// <param name="outterRadius">多边形的外接圆半径。</param> /// <param name="points">多边形的边数。</param> /// <param name="angleOffset">X轴顶角坐标偏移度数。</param> /// <returns>正多边形的顶点数组。</returns> public static PointF[] CreateRegularPolygon(PointF pivot, float outterRadius, int points, float angleOffset) { if (outterRadius < 0) { throw new ArgumentOutOfRangeException("outterRadius", "多边形的外接圆半径必须大于0"); } if (points < 3) { throw new ArgumentOutOfRangeException("points", "多边形的边数必须大于等于3"); } PointF[] ret = new PointF[points]; CircleF c = new CircleF(pivot, outterRadius); float ang = 360.0f / points; for (int i = 0; i < points; i++) { ret[i] = c.PointOnPath(angleOffset + i * ang); } return(ret); }
/// <summary> /// 创建一个几何规则的星形 /// </summary> /// <param name="pivot">星形的几何中心坐标</param> /// <param name="outterRadius">星形的外环半径</param> /// <param name="innerRadius">星形的内环半径</param> /// <param name="points">星形的顶角数</param> /// <param name="angleOffset">X轴顶角坐标偏移度数。</param> /// <returns>星形的GraphicsPath对象</returns> public static GraphicsPath CreateStar(PointF pivot, float outterRadius, float innerRadius, int points, float angleOffset) { if (outterRadius <= innerRadius) { throw new ArgumentException("参数outterRadius必须大于innerRadius。"); } if (points < 2) { throw new ArgumentOutOfRangeException("points"); } GraphicsPath gp = new GraphicsPath(); CircleF outter = new CircleF(pivot, outterRadius); CircleF inner = new CircleF(pivot, innerRadius); float ang = 360.0f / points; for (int i = 0; i < points; i++) { gp.AddLine(outter.PointOnPath(angleOffset + i * ang), inner.PointOnPath(angleOffset + i * ang + ang / 2.0f)); } gp.CloseFigure(); return(gp); }
/// <summary> /// 创建进度圆环的各个叶瓣的轮廓线 /// </summary> /// <param name="pivot">进度圆环的几何中心坐标</param> /// <param name="outterRadius">进度圆环的外边界半径</param> /// <param name="innerRadius">进度圆环的内边界半径</param> /// <param name="spokes">进度圆环的叶瓣数量</param> /// <param name="angleOffset">X轴顶角坐标偏移度数</param> /// <returns>组成进度圆环的各个叶瓣的轮廓线坐标链表</returns> public static List<PointF[]> CreateWaitCircleSpokes(PointF pivot, float outterRadius, float innerRadius, int spokes, float angleOffset) { if (spokes < 1) throw new ArgumentException("参数spokes必须大于等于1。"); List<PointF[]> lst = new List<PointF[]>(); CircleF outter = new CircleF(pivot, outterRadius); CircleF inner = new CircleF(pivot, innerRadius); float ang = 360.0f / spokes; for (int i = 0; i < spokes; i++) { lst.Add(new PointF[2] { outter.PointOnPath(angleOffset + i * ang), inner.PointOnPath(angleOffset + i * ang) }); } return lst; }
/// <summary> /// 创建一个几何规则的星形 /// </summary> /// <param name="pivot">星形的几何中心坐标</param> /// <param name="outterRadius">星形的外环半径</param> /// <param name="innerRadius">星形的内环半径</param> /// <param name="points">星形的顶角数</param> /// <param name="angleOffset">X轴顶角坐标偏移度数。</param> /// <returns>星形的GraphicsPath对象</returns> public static GraphicsPath CreateStar(PointF pivot, float outterRadius, float innerRadius, int points, float angleOffset) { if (outterRadius <= innerRadius) throw new ArgumentException("参数outterRadius必须大于innerRadius。"); if (points < 2) throw new ArgumentOutOfRangeException("points"); GraphicsPath gp = new GraphicsPath(); CircleF outter = new CircleF(pivot, outterRadius); CircleF inner = new CircleF(pivot, innerRadius); float ang = 360.0f / points; for (int i = 0; i < points; i++) { gp.AddLine(outter.PointOnPath(angleOffset + i * ang), inner.PointOnPath(angleOffset + i * ang + ang / 2.0f)); } gp.CloseFigure(); return gp; }
/// <summary> /// 创建正多边形的顶点数组。 /// </summary> /// <param name="pivot">正多边形的几何中心坐标。</param> /// <param name="outterRadius">多边形的外接圆半径。</param> /// <param name="points">多边形的边数。</param> /// <param name="angleOffset">X轴顶角坐标偏移度数。</param> /// <returns>正多边形的顶点数组。</returns> public static PointF[] CreateRegularPolygon(PointF pivot, float outterRadius, int points, float angleOffset) { if (outterRadius < 0) throw new ArgumentOutOfRangeException("outterRadius", "多边形的外接圆半径必须大于0"); if (points < 3) throw new ArgumentOutOfRangeException("points", "多边形的边数必须大于等于3"); PointF[] ret = new PointF[points]; CircleF c = new CircleF(pivot, outterRadius); float ang = 360.0f / points; for (int i = 0; i < points; i++) { ret[i] = c.PointOnPath(angleOffset + i * ang); } return ret; }