Exemple #1
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>()
        {
        });
    }
        /// <summary>
        /// Creates point with absolute coorindates.
        /// </summary>
        /// <param name="x">Raw X-coordinate value.</param>
        /// <param name="y">Raw Y-coordinate value.</param>
        /// <param name="segments">Current path segments.</param>
        /// <param name="isRelativeX"><b>true</b> if <paramref name="x"/> contains relative coordinate value, otherwise <b>false</b>.</param>
        /// <param name="isRelativeY"><b>true</b> if <paramref name="y"/> contains relative coordinate value, otherwise <b>false</b>.</param>
        /// <returns><see cref="PointF"/> that contains absolute coordinates.</returns>
        private static PointF ToAbsolute(float x, float y, SvgPathSegmentList segments, bool isRelativeX, bool isRelativeY)
        {
            var point = new PointF(x, y);

            if ((isRelativeX || isRelativeY) && segments.Count > 0)
            {
                SvgPathSegment lastSegment = segments.Last;


                // if the last element is a SvgClosePathSegment
                // the position of the previous element should be used
                // because the position of SvgClosePathSegment is 0,0
                if (lastSegment is SvgClosePathSegment)
                {
                    SvgMoveToSegment lastMoveSegment = null;

                    for (int i = segments.Count - 1; i >= 0; --i)
                    {
                        if (segments[i] is SvgMoveToSegment)
                        {
                            lastMoveSegment = (SvgMoveToSegment)segments[i];
                            break;
                        }
                    } // Next i

                    lastSegment = lastMoveSegment; // segments.Reverse().OfType<SvgMoveToSegment>().First();
                } // End if (lastSegment is SvgClosePathSegment)

                if (isRelativeX)
                {
                    point.X += lastSegment.End.X;
                }

                if (isRelativeY)
                {
                    point.Y += lastSegment.End.Y;
                }
            }

            return(point);
        }
Exemple #3
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);
    }