Beispiel #1
0
        private static SvgPath ConvertArc(Arc arc)
        {
            SvgPath svgPath = new SvgPath();

            SvgPathSegmentList svgPathSegmentList = new SvgPathSegmentList();

            svgPathSegmentList.Add(new SvgMoveToSegment(arc.GetEndPoint(0).ConvertToPointF()));

            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);
            svgPath.PathData = svgPathSegmentList;

            return(svgPath);
        }
Beispiel #2
0
    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>()
        {
        });
    }
Beispiel #3
0
 public static TempContext <SvgArcSegment> Borrow(out SvgArcSegment arc)
 {
     if (!Temp <SvgArcSegment> .IsInit())
     {
         Temp <SvgArcSegment> .SetNewHandler(() => new SvgArcSegment());
     }
     return(Temp <SvgArcSegment> .Borrow(out arc));
 }
Beispiel #4
0
 private void addCorner(GraphicsPath path, Vector2 start, Vector2 corner, Vector2 end, float rx, float ry)
 {
     if (rx == ry)
     {
         SvgArcSegment.AddToPath(_path, start, end, rx, ry, 90, SvgArcSize.Small, SvgArcSweep.Positive);
     }
     else
     {
         path.AddElement(new BezierElement(start, corner, corner, end));
     }
 }
Beispiel #5
0
        private static SvgArcSegment MakeSlotArc(float radius, float x, float y)
        {
            var arc = new SvgArcSegment(
                new PointF(-x, y),
                radius.Px(),
                radius.Px(),
                0f,
                SvgArcSize.Small,
                SvgArcSweep.Positive,
                new PointF(x, y));

            return(arc);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
    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>()
        {
        });
    }
    protected void DrawArc(SvgDocument source, PointF center, float radius, PointF startPoint, PointF endPoint, bool largeArc = false)
    {
        SvgPath svgPath = new SvgPath()
        {
            Fill        = new SvgColourServer(Color.Transparent),
            StrokeWidth = MandalaGenerator.StrokeWidth,
            Stroke      = new SvgColourServer(Color.Black)
        };

        svgPath.PathData = new SvgPathSegmentList();

        SvgMoveToSegment svgStartMove = new SvgMoveToSegment(startPoint);

        svgPath.PathData.Add(svgStartMove);

        SvgArcSize size = largeArc ? SvgArcSize.Large : SvgArcSize.Small;

        SvgArcSegment arc = new SvgArcSegment(startPoint, radius, radius, 0, size, SvgArcSweep.Negative, endPoint);

        svgPath.PathData.Add(arc);

        source.Children.Add(svgPath);
    }