public override List <MandalaElement> Apply(MandalaElement sourceElement) { // Convert source to correct type ME_CircleSector source = (ME_CircleSector)sourceElement; SvgPath svgPath = new SvgPath() { Fill = Colour, StrokeWidth = 0 }; svgPath.PathData = new SvgPathSegmentList(); SvgMoveToSegment svgStartMove = new SvgMoveToSegment(source.InnerVertex); svgPath.PathData.Add(svgStartMove); SvgLineSegment line = new SvgLineSegment(source.InnerVertex, source.OuterVertex1); svgPath.PathData.Add(line); SvgArcSegment arc = new SvgArcSegment(source.OuterVertex1, source.OuterRadius, source.OuterRadius, 0, SvgArcSize.Small, SvgArcSweep.Negative, source.OuterVertex2); svgPath.PathData.Add(arc); source.SvgDocument.Children.Add(svgPath); return(new List <MandalaElement>() { }); }
/// <exception cref="ArgumentNullException"><paramref name="svgPath" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="svgLineSegment" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="sourceMatrix" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="viewMatrix" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="zplContainer" /> is <see langword="null" />.</exception> protected virtual void TranslateSvgLineSegment([NotNull] SvgPath svgPath, [NotNull] SvgLineSegment svgLineSegment, [NotNull] Matrix sourceMatrix, [NotNull] Matrix viewMatrix, [NotNull] ZplContainer zplContainer) { if (svgPath == null) { throw new ArgumentNullException(nameof(svgPath)); } if (svgLineSegment == null) { throw new ArgumentNullException(nameof(svgLineSegment)); } if (sourceMatrix == null) { throw new ArgumentNullException(nameof(sourceMatrix)); } if (viewMatrix == null) { throw new ArgumentNullException(nameof(viewMatrix)); } if (zplContainer == null) { throw new ArgumentNullException(nameof(zplContainer)); } var svgLine = new SvgLine { Color = svgPath.Color, Stroke = svgPath.Stroke, StrokeWidth = svgPath.StrokeWidth, StartX = svgLineSegment.Start.X, StartY = svgLineSegment.Start.Y, EndX = svgLineSegment.End.X, EndY = svgLineSegment.End.Y }; this.ZplTransformer.Transform(svgLine, sourceMatrix, viewMatrix, out var startX, out var startY, out var endX, out var endY, out var strokeWidth); var horizontalStart = (int)startX; var verticalStart = (int)endY; var width = (int)(endX - startX); var height = (int)(endY - startY); var thickness = (int)strokeWidth; zplContainer.Body.Add(this.ZplCommands.FieldTypeset(horizontalStart, verticalStart)); zplContainer.Body.Add(this.ZplCommands.GraphicBox(width, height, thickness, LineColor.Black)); }
private static SvgPath ConvertLine(Line line) { SvgPath svgPath = new SvgPath(); SvgPathSegmentList svgPathSegmentList = new SvgPathSegmentList(); svgPathSegmentList.Add(new SvgMoveToSegment(line.GetEndPoint(0).ConvertToPointF())); SvgLineSegment svgLineSegment = new SvgLineSegment(svgPathSegmentList.Last.End, line.GetEndPoint(1).ConvertToPointF()); svgPathSegmentList.Add(svgLineSegment); svgPath.PathData = svgPathSegmentList; return(svgPath); }
private static SvgPath ConverPolyCurve(List <Curve> curves) { SvgPath svgPath = new SvgPath(); SvgPathSegmentList svgPathSegmentList = new SvgPathSegmentList(); svgPathSegmentList.Add(new SvgMoveToSegment(curves[0].GetEndPoint(0).ConvertToPointF())); foreach (Curve curve in curves) { if (curve is Arc) { Arc arc = (Arc)curve; XYZ a = arc.GetEndPoint(0) - arc.Center; XYZ b = arc.GetEndPoint(1) - arc.Center; double angleAboutAxis = a.AngleOnPlaneTo(b, arc.Normal); SvgArcSweep svgArcSweep = SvgArcSweep.Positive; if (angleAboutAxis >= 180) { svgArcSweep = SvgArcSweep.Negative; } SvgArcSize svgArcSize = SvgArcSize.Small; SvgArcSegment svgArcSegment = new SvgArcSegment(svgPathSegmentList.Last.End, (float)arc.Radius, (float)arc.Radius, (float)angleAboutAxis, svgArcSize, svgArcSweep, arc.GetEndPoint(1).ConvertToPointF()); svgPathSegmentList.Add(svgArcSegment); } else if (curve is Line) { SvgLineSegment svgLineSegment = new SvgLineSegment(svgPathSegmentList.Last.End, ((Line)curve).GetEndPoint(1).ConvertToPointF()); svgPathSegmentList.Add(svgLineSegment); } } svgPath.PathData = svgPathSegmentList; return(svgPath); }
public override List <MandalaElement> Apply(MandalaElement sourceElement) { // Convert source to correct type ME_Empty source = (ME_Empty)sourceElement; SvgPath svgPath = new SvgPath() { Fill = new SvgColourServer(Color.Black), StrokeWidth = 0 }; svgPath.PathData = new SvgPathSegmentList(); float startX = 420; float startY = 420; PointF startPoint = new PointF(startX, startY); SvgMoveToSegment svgStartMove = new SvgMoveToSegment(startPoint); svgPath.PathData.Add(svgStartMove); float x2 = 500; float y2 = 500; PointF p2 = new PointF(x2, y2); SvgLineSegment line = new SvgLineSegment(startPoint, p2); svgPath.PathData.Add(line); float x3 = 500; float y3 = 300; PointF p3 = new PointF(x3, y3); SvgArcSegment arc = new SvgArcSegment(p2, 50, 50, 0, SvgArcSize.Small, SvgArcSweep.Negative, p3); svgPath.PathData.Add(arc); source.SvgDocument.Children.Add(svgPath); return(new List <MandalaElement>() { }); }
/// <exception cref="ArgumentNullException"><paramref name="svgPath" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="svgLineSegment" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="sourceMatrix" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="viewMatrix" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="fingerPrintContainer" /> is <see langword="null" />.</exception> protected virtual void TranslateSvgLineSegment([NotNull] SvgPath svgPath, [NotNull] SvgLineSegment svgLineSegment, [NotNull] Matrix sourceMatrix, [NotNull] Matrix viewMatrix, [NotNull] FingerPrintContainer fingerPrintContainer) { if (svgPath == null) { throw new ArgumentNullException(nameof(svgPath)); } if (svgLineSegment == null) { throw new ArgumentNullException(nameof(svgLineSegment)); } if (sourceMatrix == null) { throw new ArgumentNullException(nameof(sourceMatrix)); } if (viewMatrix == null) { throw new ArgumentNullException(nameof(viewMatrix)); } if (fingerPrintContainer == null) { throw new ArgumentNullException(nameof(fingerPrintContainer)); } var svgLine = new SvgLine { Color = svgPath.Color, Stroke = svgPath.Stroke, StrokeWidth = svgPath.StrokeWidth, StartX = svgLineSegment.Start.X, StartY = svgLineSegment.Start.Y, EndX = svgLineSegment.End.X, EndY = svgLineSegment.End.Y }; this.FingerPrintTransformer.Transform(svgLine, sourceMatrix, viewMatrix, out var startX, out var startY, out var endX, out var endY, out var strokeWidth); var horizontalStart = (int)startX; var verticalStart = (int)startY; var length = (int)(endX - startX); if (length == 0) { length = (int)strokeWidth; } var lineWeight = (int)(endY - startY); if (lineWeight == 0) { lineWeight = (int)strokeWidth; } fingerPrintContainer.Body.Add(this.FingerPrintCommands.Position(horizontalStart, verticalStart)); fingerPrintContainer.Body.Add(this.FingerPrintCommands.Direction(Direction.LeftToRight)); fingerPrintContainer.Body.Add(this.FingerPrintCommands.Align(Alignment.TopLeft)); fingerPrintContainer.Body.Add(this.FingerPrintCommands.Line(length, lineWeight)); }
/// <exception cref="ArgumentNullException"><paramref name="svgPath" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="svgLineSegment" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="sourceMatrix" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="viewMatrix" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="eplContainer" /> is <see langword="null" />.</exception> protected virtual void TranslateSvgLineSegment([NotNull] SvgPath svgPath, [NotNull] SvgLineSegment svgLineSegment, [NotNull] Matrix sourceMatrix, [NotNull] Matrix viewMatrix, [NotNull] EplContainer eplContainer) { if (svgPath == null) { throw new ArgumentNullException(nameof(svgPath)); } if (svgLineSegment == null) { throw new ArgumentNullException(nameof(svgLineSegment)); } if (sourceMatrix == null) { throw new ArgumentNullException(nameof(sourceMatrix)); } if (viewMatrix == null) { throw new ArgumentNullException(nameof(viewMatrix)); } if (eplContainer == null) { throw new ArgumentNullException(nameof(eplContainer)); } var svgLine = new SvgLine { Color = svgPath.Color, Stroke = svgPath.Stroke, StrokeWidth = svgPath.StrokeWidth, StartX = svgLineSegment.Start.X, StartY = svgLineSegment.Start.Y, EndX = svgLineSegment.End.X, EndY = svgLineSegment.End.Y }; this.EplTransformer.Transform(svgLine, sourceMatrix, viewMatrix, out var startX, out var startY, out var endX, out var endY, out var strokeWidth); var horizontalStart = (int)startX; var verticalStart = (int)startY; var horizontalLength = (int)(endX - startX); if (horizontalLength == 0) { horizontalLength = (int)strokeWidth; } var verticalLength = (int)(endY - startY); if (verticalLength == 0) { verticalLength = (int)strokeWidth; } eplContainer.Body.Add(this.EplCommands.LineDrawBlack(horizontalStart, verticalStart, horizontalLength, verticalLength)); }