예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InternalPath" /> class.
 /// </summary>
 /// <param name="prototype">The prototype.</param>
 /// <param name="isClosedPath">if set to <c>true</c> [is closed path].</param>
 internal InternalPath(InternalPath prototype, bool isClosedPath)
 {
     this.points        = prototype.points;
     this.distance      = prototype.distance;
     this.calculated    = prototype.calculated;
     this.Bounds        = prototype.Bounds;
     this.closedPath    = isClosedPath;
     this.totalDistance = new Lazy <float>(this.CalculateLength);
 }
예제 #2
0
        /// <summary>
        /// Finds the intersections.
        /// </summary>
        /// <param name="start">The start.</param>
        /// <param name="end">The end.</param>
        /// <returns>The points along the line the intersect with the boundaries of the polygon.</returns>
        internal static IEnumerable <PointF> FindIntersections(this InternalPath path, Vector2 start, Vector2 end)
        {
            var results = new List <PointF>();

            PointF[] buffer = ArrayPool <PointF> .Shared.Rent(path.PointCount);

            try
            {
                int hits = path.FindIntersections(start, end, buffer);
                for (int i = 0; i < hits; i++)
                {
                    results.Add(buffer[i]);
                }
            }
            finally
            {
                ArrayPool <PointF> .Shared.Return(buffer);
            }

            return(results);
        }
예제 #3
0
 private EllipsePolygon(CubicBezierLineSegment segment)
 {
     this.segment   = segment;
     this.innerPath = new InternalPath(segment, isClosedPath: true);
 }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Path"/> class.
 /// </summary>
 /// <param name="segments">The segments.</param>
 public Path(ImmutableArray <ILineSegment> segments)
 {
     this.innerPath    = new InternalPath(segments, false);
     this.LineSegments = segments;
 }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Path"/> class.
 /// </summary>
 /// <param name="segments">The segments.</param>
 public Path(ImmutableArray <ILineSegment> segments)
 {
     this.innerPath    = new InternalPath(segments, this.IsClosed);
     this.LineSegments = segments;
     this.flatPath     = ImmutableArray.Create <ISimplePath>(this);
 }
예제 #6
0
 private Ellipse(BezierLineSegment segment)
 {
     this.segment   = segment;
     this.innerPath = new InternalPath(segment, true);
     this.flatPath  = ImmutableArray.Create <ISimplePath>(this);
 }