圆的实现原理:以中心点为一点,半径为一条边,旋转1弧度为顶角,连接弧度之间的两个顶点,组成一个三角形,循环360弧度,形成圆。

- /// <summary>
- /// 360度画圆
- /// </summary>
- /// <param name="radius">半径</param>
- /// <param name="centerP">中心点</param>
- /// <param name="color">填充色</param>
- /// <returns>返回Graphic</returns>
- public static Graphic GetEllipseGraphic(double radius, ComPoint centerP, string color)
- {
- Graphic result = new Graphic();
- List<MapPoint> points = new List<MapPoint>();
- for (double i = 0; i <= 360; i++)
- {
- points.Add(new MapPoint((centerP.X - Math.Cos(Math.PI * i / 180.0) * radius), (centerP.Y - Math.Sin(Math.PI * i / 180.0) * radius)));
- }
- PointCollection pCollection = new PointCollection(points);
- Polygon g = new Polygon();
- g.Rings.Add(pCollection);
- result.Geometry = g;
- result.Symbol = Tools.DrawStyleTools.GetEllipseFillSymbol(color);//这里根据自己的需要定义样式
- return result;
- }
复制代码