/// <summary> /// 绘制贝塞尔曲线 /// </summary> /// <param name="color"></param> public void drawBezier(string name, Color color) { Point[] tmp = controlPoints.ToArray(); curBezier = new CG_Bezier(); curBezier.ControlPoints = tmp; curBezier.Name = name; curBezier.generateBezier(); listBezier.AddLast(curBezier); Point[] points = curBezier.getPoints(); Point prev = points[0]; for (int i = 1; i < points.Count(); i++) { drawLine_Bresenham(prev, points[i], color); prev = points[i]; } controlPoints.Clear(); }
/// <summary> /// 根据名称改变当前curXXX所指向的图元,返回值表示所选中的图元类型 /// </summary> /// <param name="name">名称</param> /// <returns>line直线 circle圆 polygon多边形 rectangle矩形</returns> public string changeCurPrimitive(string name) { LinkedListNode <CG_Line> curL = listLine.First; while (curL != null) { if (curL.Value.Name == name) { curLine = curL.Value; return("line"); } curL = curL.Next; } LinkedListNode <CG_Circle> curC = listCircle.First; while (curC != null) { if (curC.Value.Name == name) { curCircle = curC.Value; return("circle"); } curC = curC.Next; } LinkedListNode <CG_Polygon> curPol = listPolygon.First; while (curPol != null) { if (curPol.Value.Name == name) { curPolygon = curPol.Value; return("polygon"); } curPol = curPol.Next; } LinkedListNode <CG_Rectangle> curRec = listRectangle.First; while (curRec != null) { if (curRec.Value.Name == name) { curRectangle = curRec.Value; return("rectangle"); } curRec = curRec.Next; } LinkedListNode <CG_Bezier> curBez = listBezier.First; while (curBez != null) { if (curBez.Value.Name == name) { curBezier = curBez.Value; return("bezier"); } curBez = curBez.Next; } return(null); }