/// <summary> /// Draws an ovoid: a closed Catmull-Rom spline. /// </summary> /// <param name="pts">Control Points</param> /// <param name="fillStr">Fill color</param> /// <param name="outlineStr">Outline color</param> public void DrawOvoid(String fillStr, String outlineStr, Path pts ) { int numPts = pts.Count(); Path final = new Path(); for (int i = 0; i < numPts; i++) { Point2D P0 = pts[(i - 1 + numPts) % numPts]; Point2D P1 = pts[i]; Point2D P2 = pts[(i + 1) % numPts]; Point2D P3 = pts[(i + 2) % numPts]; for (int j = 0; j < resolution; j++) { double t = (double)j / resolution; final.AddPt( 0.5 * ((2.0 * P1) + (-P0 + P2) * t + (2 * P0 - 5 * P1 + 4 * P2 - P3) * t * t + (-P0 + 3 * P1 - 3 * P2 + P3) * t * t * t) ); } } DrawPoly(fillStr, outlineStr, final); }
/// <summary> /// Draws a polygon /// </summary> /// <param name="vertices">Vertices</param> /// <param name="fillStr">Fill color</param> /// <param name="outlineStr">Outline color</param> public void DrawPoly(String fillStr, String outlineStr, Path pts ) { StartDrawingObject(); //output path for (int i = 0; i < pts.Count(); i++) { m_sw.Write( "\t" + pts[i].X + " " + pts[i].Y + " " ); m_sw.WriteLine( i==0 ? "moveto" : "lineto" ); } EndDrawingObject(fillStr, outlineStr); }