/// <summary> /// Draws a closed form with N splines /// The last point of spline N should be the same as the first point of spline N+1 /// </summary> /// <param name="splines">The control points for the top spline</param> /// <param name="bottom">The control points for the top spline</param> /// <param name="fillStr">Color to fill the figure</param> /// <param name="outlineStr">Color to outline the figure</param> public void DrawCatmullRomSplines(String fillStr, String outlineStr, params Path[] splines) { Path final = new Path(); foreach (Path spline in splines) { for (int i = 0; i <= resolution; i++) { final.AddControlPt(spline.getSplinePt((double)i / resolution)); } } DrawPoly(fillStr, outlineStr, final); }
Path subPath(double start, double end, PathType type) { Path result = new Path(); for (int i = 0; i < 20; i++) { double t = (double)i / 20.0; t *= end - start; t += start; result.AddControlPt( getPt( t, type) ); } return result; }
public Path reversed() { Path result = new Path(); for (int i = Count() - 1; i >= 0; i--) result.AddControlPt(m_Points[i]); return result; }
/// <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 DrawClosedCatmullRomSpline(String fillStr, String outlineStr, Path pts) { Path final = new Path(); for (int i = 0; i < resolution; i++) { final.AddControlPt(pts.getOvoidPt((double)i / resolution)); } DrawPoly(fillStr, outlineStr, final); }
Path getPath(double U1, double V1, double U2, double V2, int numPts) { Path newPath = new Path(); for (int i = 0; i < numPts; i++) { double t = (double)i / (numPts - 1); newPath.AddControlPt( this[U1 + t * (U2 - U1), V1 + t * (V2 - V1)]); } return newPath; }
public void DrawSun(double radius, double thickness) { Path circle = new Path(); Point2D center = new Point2D(595, 842) / 2.0; for (int i = 0; i < 50; i++) { double t = (double)i / 50 * Math.PI * 2.0; circle.AddControlPt(center + Point2D.FromPolar(radius, t - Math.PI / 2.0)); } for (int i = 0; i < 7; i++) { Path subPath = circle.subPathOvoid((double)(i + 0.5) / 8.0, (double)(i + 1.5) / 8.0); if (i % 2 == 0) { GridSpace ray = GridSpace.fromPath(subPath, -2.0 * radius, radius * 1.0); DrawStackedUform("white", "black", ray, thickness); } else { GridSpace ray = GridSpace.fromPath(subPath, -2.0 * radius, radius * 0.75); DrawBakersUform1(ray, thickness); } } m_file.DrawCircle(center, radius, "black", "none"); m_file.DrawCircle(center, radius - thickness*0.6, "white", "none"); DrawEyeInBox( "white", "black", new GridSpace(center + new Point2D(radius * -0.75, 0), center + new Point2D(-thickness * 0.6, 0), center + new Point2D(radius * -0.75, radius * 0.5), center + new Point2D(-thickness * 0.6, radius * 0.5)), thickness*0.6); DrawEyeInBox( "white", "black", new GridSpace(center + new Point2D(thickness * 0.6, 0), center + new Point2D(radius * 0.75, 0), center + new Point2D(thickness * 0.6, radius * 0.5), center + new Point2D(radius * 0.75, radius * 0.5)), thickness*0.6); }