Ejemplo n.º 1
0
 /// <summary>
 /// Ends the current figure; optionally, closes it.
 /// </summary>
 /// <param name="figureLoop"> The figure-loop. </param>
 public void EndFigure(CanvasFigureLoop figureLoop)
 {
     this.Add(new Node
     {
         Type       = NodeType.EndFigure,
         FigureLoop = figureLoop,
     });
 }
Ejemplo n.º 2
0
        public override string CanvasFigureLoop(CanvasFigureLoop value)
        {
            var typeName = nameof(CanvasFigureLoop);

            return(value switch
            {
                Mgcg.CanvasFigureLoop.Open => $"{typeName}{ScopeResolve}Open",
                Mgcg.CanvasFigureLoop.Closed => $"{typeName}{ScopeResolve}Closed",
                _ => throw new InvalidOperationException(),
            });
Ejemplo n.º 3
0
        public void EndFigure(CanvasFigureLoop figureLoop)
        {
            if (figureLoop == CanvasFigureLoop.Closed)
            {
                _currentGlyph.Add(new LinePath(_lastPoint, _startPoint));
            }
            allGlyphs.Add(_currentGlyph);
            // start a new block
            _currentGlyph = new TextGlyph();

            System.Diagnostics.Debug.WriteLine(">>>>>");
        }
Ejemplo n.º 4
0
        public virtual string CanvasFigureLoop(CanvasFigureLoop value)
        {
            var typeName = nameof(CanvasFigureLoop);

            switch (value)
            {
            case Mgcg.CanvasFigureLoop.Open: return($"{typeName}{ScopeResolve}Open");

            case Mgcg.CanvasFigureLoop.Closed: return($"{typeName}{ScopeResolve}Closed");

            default: throw new InvalidOperationException();
            }
        }
Ejemplo n.º 5
0
            public override string CanvasFigureLoop(CanvasFigureLoop value)
            {
                switch (value)
                {
                case Mgcg.CanvasFigureLoop.Open:
                    return("CanvasFigureLoop.Open");

                case Mgcg.CanvasFigureLoop.Closed:
                    return("CanvasFigureLoop.Closed");

                default:
                    throw new InvalidOperationException();
                }
            }
Ejemplo n.º 6
0
            public void EndFigure(CanvasFigureLoop figureLoop)
            {
                if (figureTopEdge == null || figureBottomEdge == null)
                {
                    return; // The figure's area doesn't comprise a line.
                }
                float left  = System.Math.Max(figureTopEdge[0], figureBottomEdge[0]);
                float right = System.Math.Min(figureTopEdge[1], figureBottomEdge[1]);

                float width = right - left;

                if (width > 0)
                {
                    Rect rect = new Rect(left, lineRegion.Top, width, lineRegion.Height);
                    unsortedOutput.Add(rect);
                }
            }
        /// <summary>
        /// Builds a path with the given collection of points.
        /// </summary>
        /// <param name="builder">CanvasPathBuilder</param>
        /// <param name="canvasFigureLoop">Specifies whether the figure is open or closed.
        /// This affects the appearance of fills and strokes, as well as geometry operations.</param>
        /// <param name="points">Collection of Vector2 points on the path.</param>
        /// <returns>CanvasPathBuilder</returns>
        public static CanvasPathBuilder BuildPathWithLines(this CanvasPathBuilder builder,
                                                           CanvasFigureLoop canvasFigureLoop, IEnumerable <Vector2> points)
        {
            var first = true;

            foreach (var point in points)
            {
                if (first)
                {
                    builder.BeginFigure(point);
                    first = false;
                }
                else
                {
                    builder.AddLine(point);
                }
            }

            builder.EndFigure(canvasFigureLoop);
            return(builder);
        }
Ejemplo n.º 8
0
            public void EndFigure(CanvasFigureLoop figureLoop)
            {
                if (figureTopEdge == null || figureBottomEdge == null)
                {
                    figureIsValid = false;
                }

                if (figureIsValid)
                {
                    float left  = System.Math.Max(figureTopEdge[0], figureBottomEdge[0]);
                    float right = System.Math.Min(figureTopEdge[1], figureBottomEdge[1]);

                    float width = right - left;

                    if (width > 0)
                    {
                        Rect rect = new Rect(left, lineRegion.Top, width, lineRegion.Height);
                        unsortedOutput.Add(rect);
                    }
                }
            }
Ejemplo n.º 9
0
        public void EndFigure(CanvasFigureLoop figureLoop)
        {
            if (figureLoop == CanvasFigureLoop.Closed)
            {
                if (Path.Points.Count > 1)  // what we really want to check here is non-null area, but that's not important
                {
                    var first = Path.Points.First();
                    var last  = Path.Points.Last();

                    if (first.X == last.X && first.Y == last.Y)
                    {
                        Path.Points.RemoveAt(0);
                    }
                }
                if (Path.IsOpen)
                {
                    Path.Close();
                }

                if (Path.Points.Count > 2)
                {
                    var prev  = Path.Points[Path.Points.Count - 2];
                    var point = Path.Points[Path.Points.Count - 1];
                    foreach (var next in Path.Points)
                    {
                        if (point.Type != Data.PointType.None &&
                            (prev.Type == Data.PointType.None || next.Type == Data.PointType.None) &&
                            IsFlatAngle(prev, point, next))
                        {
                            point.IsSmooth = true;
                        }

                        prev  = point;
                        point = next;
                    }
                }
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// >Ends the current figure; optionally, closes it.
 /// </summary>
 /// <param name="figureLoop"><see cref="CanvasFigureLoop"/></param>
 public void EndFigure(CanvasFigureLoop figureLoop)
 {
     _cmdBuilder.AppendLine($"    pathBuilder.EndFigure({(figureLoop == CanvasFigureLoop.Closed ? "CanvasFigureLoop.Closed" : "CanvasFigureLoop.Open")});");
 }
Ejemplo n.º 11
0
 public abstract string CanvasFigureLoop(CanvasFigureLoop value);
 string CanvasFigureLoop(CanvasFigureLoop value) => _stringifier.CanvasFigureLoop(value);
Ejemplo n.º 13
0
 public void EndFigure(CanvasFigureLoop figureLoop)
 {
     wasEndFigureCalled = true;
 }
Ejemplo n.º 14
0
 public void EndFigure(CanvasFigureLoop figureLoop)
 {
     _builder.Append("Z ");
 }
Ejemplo n.º 15
0
 public void EndFigure(CanvasFigureLoop figureLoop)
 {
 }
Ejemplo n.º 16
0
 internal EndFigure(CanvasFigureLoop figureLoop)
 {
     FigureLoop = figureLoop;
 }
Ejemplo n.º 17
0
 public void EndFigure(CanvasFigureLoop figureLoop)
 {
     _commands.Add(new Command.EndFigure(figureLoop));
 }
Ejemplo n.º 18
0
 public void EndFigure(CanvasFigureLoop figureLoop)
 {
     Parts.Add("Z");
 }
Ejemplo n.º 19
0
 public void EndFigure(CanvasFigureLoop figureLoop)
 {
     wasEndFigureCalled = true;
 }
Ejemplo n.º 20
0
 public void ClosePath()
 {
     mFigureLoop = CanvasFigureLoop.Closed;
 }
Ejemplo n.º 21
0
 public void EndFigure(CanvasFigureLoop arg)
 {
 }
 /// <summary>
 /// Builds a path with the given collection of points in the (x, y) pattern.
 /// </summary>
 /// <param name="builder">CanvasPathBuilder</param>
 /// <param name="canvasFigureLoop">Specifies whether the figure is open or closed.
 /// This affects the appearance of fills and strokes, as well as geometry operations.</param>
 /// <param name="nodes">Collection of points in the (x, y) pattern on the path.</param>
 /// <returns>CanvasPathBuilder</returns>
 public static CanvasPathBuilder BuildPathWithLines(this CanvasPathBuilder builder,
                                                    CanvasFigureLoop canvasFigureLoop, IEnumerable <(float x, float y)> nodes)