Ejemplo n.º 1
0
        /// <summary>
        /// Adds a series of line segments connecting the current point to the new points.
        /// </summary>
        /// <param name="points">The points.</param>
        /// <returns>The <see cref="PathBuilder"/></returns>
        public PathBuilder AddLines(IEnumerable <PointF> points)
        {
            if (points is null)
            {
                throw new ArgumentNullException(nameof(points));
            }

            using (var segment = new LinearLineSegment(PrimitiveListPools.PointF.Rent(points)))
                AddSegment(segment);
            return(this);
        }
        /// <summary>
        /// Transforms the rectangle using specified matrix.
        /// </summary>
        /// <param name="matrix">The matrix.</param>
        /// <returns>
        /// A new shape with the matrix applied to it.
        /// </returns>
        public IPath Transform(Matrix3x2 matrix)
        {
            if (IsDisposed)
            {
                throw new ObjectDisposedException(nameof(RectangularPolygon));
            }

            if (matrix.IsIdentity)
            {
                return(this);
            }

            // rectangles may be rotated and skewed which means they will then nedd representing by a polygon
            // rent _points into secondary list as disposing the linear segment recycles _points
            var secondary = PrimitiveListPools.PointF.Rent(this._points);

            using (var linear = new LinearLineSegment(secondary))
                return(new Polygon(linear.Transform(matrix)));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds a series of line segments connecting the current point to the new points.
 /// </summary>
 /// <param name="points">The points.</param>
 /// <returns>The <see cref="PathBuilder"/></returns>
 public PathBuilder AddLines(params PointF[] points)
 {
     using (var segment = new LinearLineSegment(points))
         AddSegment(segment);
     return(this);
 }