internal void Build(Pinion pinion, SvgSvgElement root) { SvgGroupElement helperLinesGroup = new SvgGroupElement("HelperLines"); helperLinesGroup.Style = Styles.HelperLineStyle; root.AddChild(helperLinesGroup); // Wheel pitch circle helperLinesGroup.AddChild(SvgHelper.CreateCircle(pinion.Center, pinion.PitchDiameter / 2.0)); // Wheel addendum circle helperLinesGroup.AddChild(SvgHelper.CreateCircle(pinion.Center, pinion.PitchDiameter / 2.0 + pinion.Addendum)); // Wheel dedendum circle helperLinesGroup.AddChild(SvgHelper.CreateCircle(pinion.Center, pinion.PitchDiameter / 2.0 - pinion.Dedendum)); // wheel center double halfCrossLength = 10; helperLinesGroup.AddChild(new SvgLineElement(pinion.Center.X - halfCrossLength, pinion.Center.Y, pinion.Center.X + halfCrossLength, pinion.Center.Y)); helperLinesGroup.AddChild(new SvgLineElement(pinion.Center.X, pinion.Center.Y - halfCrossLength, pinion.Center.X, pinion.Center.Y + halfCrossLength)); SvgGroupElement mainGroup = new SvgGroupElement("Main"); mainGroup.Style = Styles.MinorLineStyle; root.AddChild(mainGroup); PinionTooth[] teeth = pinion.GetTeeth(Math.PI / pinion.ToothCount); StringBuilder pathBuilder = new StringBuilder(); pathBuilder.AppendFormat(CultureInfo.InvariantCulture, "M{0},{1}", (float)teeth[0].DedendumIntersectLeft.X, (float)teeth[0].DedendumIntersectLeft.Y); for (int i = 0; i < teeth.Length; i++) { PinionTooth tooth = teeth[i]; PinionTooth nextTooth = teeth[(i + 1) % teeth.Length]; InsertToothPath(pinion, tooth, nextTooth, pathBuilder); } pathBuilder.Append(" z"); SvgPath svgPath = new SvgPath(pathBuilder.ToString()); SvgPathElement svgPathElement = new SvgPathElement(); svgPathElement.D = svgPath; mainGroup.AddChild(svgPathElement); if (pinion.CenterHoleDiameter > 0) { mainGroup.AddChild(SvgHelper.CreateCircle(pinion.Center, pinion.CenterHoleDiameter / 2.0)); } }
/// <summary> /// Implemented. <c>DrawPie</c> functions work correctly and thus produce different output from GDI+ if the ellipse is not circular. /// </summary> public void DrawPie(Pen pen, Single x, Single y, Single width, Single height, Single startAngle, Single sweepAngle) { string s = GDIArc2SVGPath(x,y,width,height, startAngle, sweepAngle, true); SvgPathElement pie = new SvgPathElement(); pie.D = s; pie.Style = new SvgStyle(pen); if (!_transforms.Result.IsIdentity) pie.Transform = new SvgTransformList(_transforms.Result.Clone()); _cur.AddChild(pie); }
/// <summary> /// Implemented /// </summary> public void DrawBezier(Pen pen, Single x1, Single y1, Single x2, Single y2, Single x3, Single y3, Single x4, Single y4) { SvgPathElement bez = new SvgPathElement(); bez.D = "M " + x1.ToString() + " " + y1.ToString() + " C " + x2.ToString() + " " + y2.ToString() + " " + x3.ToString() + " " + y3.ToString() + " " + x4.ToString() + " " + y4.ToString(); bez.Style = new SvgStyle(pen); if (!_transforms.Result.IsIdentity) bez.Transform = new SvgTransformList(_transforms.Result.Clone()); _cur.AddChild(bez); }
/// <summary> /// Implemented /// </summary> public void DrawBeziers(Pen pen, PointF[] points) { SvgPathElement bez = new SvgPathElement(); string s ="M " + points[0].X.ToString() + " " + points[0].Y.ToString() + " C "; for(int i=1; i < points.Length; ++i) { s += points[i].X.ToString() + " " + points[i].Y.ToString() + " "; } bez.D = s; bez.Style = new SvgStyle(pen); if (!_transforms.Result.IsIdentity) bez.Transform = new SvgTransformList(_transforms.Result.Clone()); _cur.AddChild(bez); }
private void FillBeziers(Brush brush, PointF[]points, FillMode fillmode) { SvgPathElement bez = new SvgPathElement(); string s ="M " + points[0].X.ToString() + " " + points[0].Y.ToString() + " C "; for(int i=1; i < points.Length; ++i) { s += points[i].X.ToString() + " " + points[i].Y.ToString() + " "; } s += "Z"; bez.D = s; bez.Style = HandleBrush(brush); bez.Transform = new SvgTransformList(_transforms.Result.Clone()); _cur.AddChild(bez); }
/// <summary> /// Implemented. <c>DrawArc</c> functions work correctly and thus produce different output from GDI+ if the ellipse is not circular. /// </summary> public void DrawArc(Pen pen, Single x, Single y, Single width, Single height, Single startAngle, Single sweepAngle) { string s = GDIArc2SVGPath(x, y, width, height, startAngle, sweepAngle, false); SvgPathElement arc = new SvgPathElement(); arc.D = s; arc.Style = new SvgStyle(pen); if (!_transforms.Result.IsIdentity) arc.Transform = new SvgTransformList(_transforms.Result.Clone()); _cur.AddChild(arc); }
private void AddSlice(SvgGroupElement group, double radius, double angle, double angularWidth) { PointF firstPointOnCircle = GetPointOnCircle(radius, angle - angularWidth / 2.0); PointF secondPointOnCircle = GetPointOnCircle(radius, angle + angularWidth / 2.0); // for an explanation of the arc syntax see: http://www.codestore.net/store.nsf/unid/EPSD-5DTT4L string path = String.Format( CultureInfo.InvariantCulture, "M0,0 L{0},{1} A{2},{2} 0 0,1 {3},{4} z", firstPointOnCircle.X, firstPointOnCircle.Y, (float)radius, secondPointOnCircle.X, secondPointOnCircle.Y); SvgPath svgPath = new SvgPath(path); SvgPathElement svgPathElement = new SvgPathElement(); svgPathElement.D = svgPath; group.AddChild(svgPathElement); }
private void button2_Click(object sender, System.EventArgs e) { SvgSvgElement root = new SvgSvgElement("4in", "4in", "0,0 100,100"); //adding multiple children root.AddChildren( new SvgRectElement(5,5,5,5), new SvgEllipseElement(30,10,8,12), new SvgTextElement("Textastic!", 3, 20) ); //group and path SvgGroupElement grp = new SvgGroupElement("green_group"); grp.Style = "fill:green;stroke:black;"; SvgEllipseElement ell = new SvgEllipseElement(); ell.CX = 50; ell.CY = 50; ell.RX = 10; ell.RY = 20; SvgPathElement pathy = new SvgPathElement(); pathy.D = "M 20,80 C 20,90 30,80 70,100 C 70,100 40,60 50,60 z"; pathy.Style = ell.Style; root.AddChild(grp); //cloning and style arithmetic grp.AddChildren(ell, pathy); grp.Style.Set("fill", "blue"); SvgGroupElement grp2 = (SvgGroupElement)SvgFactory.CloneElement(grp); grp2.Id = "cloned_red_group"; grp2.Style.Set("fill", "red"); grp2.Style += "opacity:0.5"; grp2.Transform = "scale (1.2, 1.2) translate(10)"; root.AddChild(grp2); //output string s = root.WriteSVGString(true); tbOut.Text = s; StreamWriter tw = new StreamWriter("c:\\temp\\foo.svg", false); tw.Write(s); tw.Close(); svgOut.SRC = "c:\\temp\\foo.svg"; }
/// <summary> /// Implemented /// </summary> public void DrawBeziers(Pen pen, PointF[] points) { var bez = new SvgPathElement(); string s = string.Format(CultureInfo.InvariantCulture, "M {0} {1} C", points[0].X, points[0].Y); for (int i = 1; i < points.Length; ++i) { s += string.Format(CultureInfo.InvariantCulture, "{0} {1} ", points[i].X, points[i].Y); } bez.D = s; bez.Style = new SvgStyle(pen); if (!transforms.Result.IsIdentity) { bez.Transform = new SvgTransformList(transforms.Result.Clone()); } cur.AddChild(bez); }
/// <summary> /// Implemented /// </summary> public void DrawBezier(Pen pen, Single x1, Single y1, Single x2, Single y2, Single x3, Single y3, Single x4, Single y4) { var bez = new SvgPathElement(); bez.D = string.Format(CultureInfo.InvariantCulture, "M {0} {1} C {2} {3} {4} {5} {6} {7}", x1, y1, x2, y2, x3, y3, x4, y4); bez.Style = new SvgStyle(pen); if (!transforms.Result.IsIdentity) { bez.Transform = new SvgTransformList(transforms.Result.Clone()); } cur.AddChild(bez); }
/// <summary> /// Implemented /// </summary> public void FillPie(Brush brush, Single x, Single y, Single width, Single height, Single startAngle, Single sweepAngle) { string s = GDIArc2SVGPath(x, y, width, height, startAngle, sweepAngle, true); var pie = new SvgPathElement(); pie.D = s; pie.Style = HandleBrush(brush); if (!transforms.Result.IsIdentity) { pie.Transform = new SvgTransformList(transforms.Result.Clone()); } cur.AddChild(pie); }