<PackageReference Include="System.Drawing.Common" Version="10.0.0-preview.5.25277.114" />

GraphicsPath

Represents a series of connected lines and curves. This class cannot be inherited.
using System.ComponentModel; using System.Drawing.Internal; using System.Runtime.CompilerServices; using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.Graphics.GdiPlus; namespace System.Drawing.Drawing2D { [NullableContext(1)] [Nullable(0)] public sealed class GraphicsPath : MarshalByRefObject, ICloneable, IDisposable { [Nullable(0)] internal unsafe GpPath* _nativePath; private const float Flatness = 0.6666667; public unsafe FillMode FillMode { get { global::Windows.Win32.Graphics.GdiPlus.FillMode result = default(global::Windows.Win32.Graphics.GdiPlus.FillMode); PInvokeGdiPlus.GdipGetPathFillMode(_nativePath, &result).ThrowIfFailed(); GC.KeepAlive(this); return (FillMode)result; } set { if ((value < FillMode.Alternate || value > FillMode.Winding) ? true : false) throw new InvalidEnumArgumentException("value", (int)value, typeof(FillMode)); PInvokeGdiPlus.GdipSetPathFillMode(_nativePath, (global::Windows.Win32.Graphics.GdiPlus.FillMode)value).ThrowIfFailed(); GC.KeepAlive(this); } } public unsafe PathData PathData { get { int pointCount = PointCount; PathData pathData = new PathData { Types = new byte[pointCount], Points = new PointF[pointCount] }; if (pointCount == 0) return pathData; fixed (byte* types = pathData.Types) { fixed (PointF* points = pathData.Points) { GpPathData gpPathData = default(GpPathData); gpPathData.Count = pointCount; gpPathData.Points = points; gpPathData.Types = types; GpPathData gpPathData2 = gpPathData; PInvokeGdiPlus.GdipGetPathData(_nativePath, (global::Windows.Win32.Graphics.GdiPlus.PathData*)(&gpPathData2)).ThrowIfFailed(); GC.KeepAlive(this); } } return pathData; } } public unsafe int PointCount { get { int result = default(int); PInvokeGdiPlus.GdipGetPointCount(_nativePath, &result).ThrowIfFailed(); GC.KeepAlive(this); return result; } } public byte[] PathTypes { get { int pointCount = PointCount; if (pointCount == 0) return Array.Empty<byte>(); byte[] array = new byte[pointCount]; GetPathTypes(array); return array; } } public PointF[] PathPoints { get { int pointCount = PointCount; if (pointCount == 0) return Array.Empty<PointF>(); PointF[] array = new PointF[pointCount]; GetPathPoints(array); return array; } } public GraphicsPath() : this(FillMode.Alternate) { } public unsafe GraphicsPath(FillMode fillMode) { GpPath* nativePath = default(GpPath*); PInvokeGdiPlus.GdipCreatePath((global::Windows.Win32.Graphics.GdiPlus.FillMode)fillMode, &nativePath).ThrowIfFailed(); _nativePath = nativePath; } public GraphicsPath(PointF[] pts, byte[] types) : this(pts, types, FillMode.Alternate) { } public GraphicsPath(PointF[] pts, byte[] types, FillMode fillMode) : this(pts.OrThrowIfNull("pts").AsSpan(), types.OrThrowIfNull("types").AsSpan(), fillMode) { } [NullableContext(0)] internal unsafe GraphicsPath(ReadOnlySpan<PointF> pts, ReadOnlySpan<byte> types, FillMode fillMode = FillMode.Alternate) { if (pts.Length != types.Length) throw Status.InvalidParameter.GetException(); fixed (PointF* ptr = &pts.GetPinnableReference()) { PointF* param = ptr; fixed (byte* param2 = &types.GetPinnableReference()) { GpPath* nativePath = default(GpPath*); PInvokeGdiPlus.GdipCreatePath2((global::Windows.Win32.Graphics.GdiPlus.PointF*)param, param2, types.Length, (global::Windows.Win32.Graphics.GdiPlus.FillMode)fillMode, &nativePath).ThrowIfFailed(); _nativePath = nativePath; } } } public GraphicsPath(Point[] pts, byte[] types) : this(pts, types, FillMode.Alternate) { } public GraphicsPath(Point[] pts, byte[] types, FillMode fillMode) : this(pts.OrThrowIfNull("pts").AsSpan(), types.OrThrowIfNull("types").AsSpan(), fillMode) { } [NullableContext(0)] internal unsafe GraphicsPath(ReadOnlySpan<Point> pts, ReadOnlySpan<byte> types, FillMode fillMode = FillMode.Alternate) { if (pts.Length != types.Length) throw Status.InvalidParameter.GetException(); fixed (byte* param2 = &types.GetPinnableReference()) { fixed (Point* param = &pts.GetPinnableReference()) { GpPath* nativePath = default(GpPath*); PInvokeGdiPlus.GdipCreatePath2I((global::Windows.Win32.Graphics.GdiPlus.Point*)param, param2, types.Length, (global::Windows.Win32.Graphics.GdiPlus.FillMode)fillMode, &nativePath).ThrowIfFailed(); _nativePath = nativePath; } } } public unsafe object Clone() { GpPath* nativePath = default(GpPath*); PInvokeGdiPlus.GdipClonePath(_nativePath, &nativePath).ThrowIfFailed(); GC.KeepAlive(this); return new GraphicsPath(nativePath); } [NullableContext(0)] private unsafe GraphicsPath(GpPath* nativePath) { if (nativePath == null) throw new ArgumentNullException("nativePath"); _nativePath = nativePath; } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } private unsafe void Dispose(bool disposing) { if (_nativePath != null) try { PInvokeGdiPlus.GdipDeletePath(_nativePath); } catch (Exception ex) when (!ClientUtils.IsSecurityOrCriticalException(ex)) { } finally { _nativePath = null; } } ~GraphicsPath() { Dispose(false); } public unsafe void Reset() { PInvokeGdiPlus.GdipResetPath(_nativePath).ThrowIfFailed(); GC.KeepAlive(this); } public unsafe void StartFigure() { PInvokeGdiPlus.GdipStartPathFigure(_nativePath); GC.KeepAlive(this); } public unsafe void CloseFigure() { PInvokeGdiPlus.GdipClosePathFigure(_nativePath).ThrowIfFailed(); GC.KeepAlive(this); } public unsafe void CloseAllFigures() { PInvokeGdiPlus.GdipClosePathFigures(_nativePath).ThrowIfFailed(); GC.KeepAlive(this); } public unsafe void SetMarkers() { PInvokeGdiPlus.GdipSetPathMarker(_nativePath).ThrowIfFailed(); GC.KeepAlive(this); } public unsafe void ClearMarkers() { PInvokeGdiPlus.GdipClearPathMarkers(_nativePath).ThrowIfFailed(); GC.KeepAlive(this); } public unsafe void Reverse() { PInvokeGdiPlus.GdipReversePath(_nativePath).ThrowIfFailed(); GC.KeepAlive(this); } public unsafe PointF GetLastPoint() { PointF result = default(PointF); PInvokeGdiPlus.GdipGetPathLastPoint(_nativePath, (global::Windows.Win32.Graphics.GdiPlus.PointF*)(&result)); GC.KeepAlive(this); return result; } public bool IsVisible(float x, float y) { return IsVisible(new PointF(x, y), null); } public bool IsVisible(PointF point) { return IsVisible(point, null); } [NullableContext(2)] public unsafe bool IsVisible(float x, float y, Graphics graphics) { BOOL value = default(BOOL); PInvokeGdiPlus.GdipIsVisiblePathPoint(_nativePath, x, y, (GpGraphics*)(long)((graphics == null) ? ((IntPtr)(void*)null) : ((IntPtr)graphics.NativeGraphics)), &value).ThrowIfFailed(); GC.KeepAlive(this); GC.KeepAlive(graphics); return value; } [NullableContext(2)] public bool IsVisible(PointF pt, Graphics graphics) { return IsVisible(pt.X, pt.Y, graphics); } public bool IsVisible(int x, int y) { return IsVisible((float)x, (float)y, null); } public bool IsVisible(Point point) { return IsVisible((PointF)point, (Graphics)null); } [NullableContext(2)] public bool IsVisible(int x, int y, Graphics graphics) { return IsVisible((float)x, (float)y, graphics); } [NullableContext(2)] public bool IsVisible(Point pt, Graphics graphics) { return IsVisible((PointF)pt, graphics); } public bool IsOutlineVisible(float x, float y, Pen pen) { return IsOutlineVisible(new PointF(x, y), pen, null); } public bool IsOutlineVisible(PointF point, Pen pen) { return IsOutlineVisible(point, pen, null); } public unsafe bool IsOutlineVisible(float x, float y, Pen pen, [Nullable(2)] Graphics graphics) { ArgumentNullException.ThrowIfNull(pen, "pen"); BOOL value = default(BOOL); PInvokeGdiPlus.GdipIsOutlineVisiblePathPoint(_nativePath, x, y, pen.NativePen, (GpGraphics*)(long)((graphics == null) ? ((IntPtr)(void*)null) : ((IntPtr)graphics.NativeGraphics)), &value).ThrowIfFailed(); GC.KeepAlive(this); GC.KeepAlive(pen); GC.KeepAlive(graphics); return value; } public bool IsOutlineVisible(PointF pt, Pen pen, [Nullable(2)] Graphics graphics) { return IsOutlineVisible(pt.X, pt.Y, pen, graphics); } public bool IsOutlineVisible(int x, int y, Pen pen) { return IsOutlineVisible(new Point(x, y), pen, null); } public bool IsOutlineVisible(Point point, Pen pen) { return IsOutlineVisible(point, pen, null); } public bool IsOutlineVisible(int x, int y, Pen pen, [Nullable(2)] Graphics graphics) { return IsOutlineVisible((float)x, (float)y, pen, graphics); } public bool IsOutlineVisible(Point pt, Pen pen, [Nullable(2)] Graphics graphics) { return IsOutlineVisible((PointF)pt, pen, graphics); } public void AddLine(PointF pt1, PointF pt2) { AddLine(pt1.X, pt1.Y, pt2.X, pt2.Y); } public unsafe void AddLine(float x1, float y1, float x2, float y2) { PInvokeGdiPlus.GdipAddPathLine(_nativePath, x1, y1, x2, y2).ThrowIfFailed(); GC.KeepAlive(this); } public void AddLines(params PointF[] points) { AddLines(points.OrThrowIfNull("points").AsSpan()); } [NullableContext(0)] private unsafe void AddLines([System.Runtime.CompilerServices.ParamCollection] [ScopedRef] ReadOnlySpan<PointF> points) { if (points.Length == 0) throw new ArgumentException(null, "points"); fixed (PointF* points2 = &points.GetPinnableReference()) { PInvokeGdiPlus.GdipAddPathLine2(_nativePath, (global::Windows.Win32.Graphics.GdiPlus.PointF*)points2, points.Length).ThrowIfFailed(); GC.KeepAlive(this); } } public void AddLine(Point pt1, Point pt2) { AddLine((float)pt1.X, (float)pt1.Y, (float)pt2.X, (float)pt2.Y); } public void AddLine(int x1, int y1, int x2, int y2) { AddLine((float)x1, (float)y1, (float)x2, (float)y2); } public void AddLines(params Point[] points) { AddLines(points.OrThrowIfNull("points").AsSpan()); } [NullableContext(0)] private unsafe void AddLines([System.Runtime.CompilerServices.ParamCollection] [ScopedRef] ReadOnlySpan<Point> points) { if (points.Length == 0) throw new ArgumentException(null, "points"); fixed (Point* points2 = &points.GetPinnableReference()) { PInvokeGdiPlus.GdipAddPathLine2I(_nativePath, (global::Windows.Win32.Graphics.GdiPlus.Point*)points2, points.Length).ThrowIfFailed(); GC.KeepAlive(this); } } public void AddArc(RectangleF rect, float startAngle, float sweepAngle) { AddArc(rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle); } public unsafe void AddArc(float x, float y, float width, float height, float startAngle, float sweepAngle) { PInvokeGdiPlus.GdipAddPathArc(_nativePath, x, y, width, height, startAngle, sweepAngle).ThrowIfFailed(); GC.KeepAlive(this); } public void AddArc(Rectangle rect, float startAngle, float sweepAngle) { AddArc(rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle); } public void AddArc(int x, int y, int width, int height, float startAngle, float sweepAngle) { AddArc((float)x, (float)y, (float)width, (float)height, startAngle, sweepAngle); } public void AddBezier(PointF pt1, PointF pt2, PointF pt3, PointF pt4) { AddBezier(pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y); } public unsafe void AddBezier(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) { PInvokeGdiPlus.GdipAddPathBezier(_nativePath, x1, y1, x2, y2, x3, y3, x4, y4).ThrowIfFailed(); GC.KeepAlive(this); } public void AddBeziers(params PointF[] points) { AddBeziers(points.OrThrowIfNull("points").AsSpan()); } [NullableContext(0)] internal unsafe void AddBeziers([System.Runtime.CompilerServices.ParamCollection] [ScopedRef] ReadOnlySpan<PointF> points) { fixed (PointF* points2 = &points.GetPinnableReference()) { PInvokeGdiPlus.GdipAddPathBeziers(_nativePath, (global::Windows.Win32.Graphics.GdiPlus.PointF*)points2, points.Length).ThrowIfFailed(); GC.KeepAlive(this); } } public void AddBezier(Point pt1, Point pt2, Point pt3, Point pt4) { AddBezier((float)pt1.X, (float)pt1.Y, (float)pt2.X, (float)pt2.Y, (float)pt3.X, (float)pt3.Y, (float)pt4.X, (float)pt4.Y); } public void AddBezier(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { AddBezier((float)x1, (float)y1, (float)x2, (float)y2, (float)x3, (float)y3, (float)x4, (float)y4); } public void AddBeziers(params Point[] points) { AddBeziers(points.OrThrowIfNull("points").AsSpan()); } [NullableContext(0)] internal unsafe void AddBeziers([System.Runtime.CompilerServices.ParamCollection] [ScopedRef] ReadOnlySpan<Point> points) { if (points.Length != 0) { fixed (Point* points2 = &points.GetPinnableReference()) { PInvokeGdiPlus.GdipAddPathBeziersI(_nativePath, (global::Windows.Win32.Graphics.GdiPlus.Point*)points2, points.Length).ThrowIfFailed(); GC.KeepAlive(this); } } } public void AddCurve(params PointF[] points) { AddCurve(points.AsSpan(), 0.5); } public void AddCurve(PointF[] points, float tension) { AddCurve(points.AsSpan(), tension); } public unsafe void AddCurve(PointF[] points, int offset, int numberOfSegments, float tension) { fixed (PointF* points2 = points) { PInvokeGdiPlus.GdipAddPathCurve3(_nativePath, (global::Windows.Win32.Graphics.GdiPlus.PointF*)points2, points.Length, offset, numberOfSegments, tension).ThrowIfFailed(); GC.KeepAlive(this); } } [NullableContext(0)] private unsafe void AddCurve(ReadOnlySpan<PointF> points, float tension) { fixed (PointF* points2 = &points.GetPinnableReference()) { PInvokeGdiPlus.GdipAddPathCurve2(_nativePath, (global::Windows.Win32.Graphics.GdiPlus.PointF*)points2, points.Length, tension).ThrowIfFailed(); GC.KeepAlive(this); } } public void AddCurve(params Point[] points) { AddCurve(points.AsSpan(), 0.5); } public void AddCurve(Point[] points, float tension) { AddCurve(points.AsSpan(), tension); } public unsafe void AddCurve(Point[] points, int offset, int numberOfSegments, float tension) { fixed (Point* points2 = points) { PInvokeGdiPlus.GdipAddPathCurve3I(_nativePath, (global::Windows.Win32.Graphics.GdiPlus.Point*)points2, points.Length, offset, numberOfSegments, tension).ThrowIfFailed(); GC.KeepAlive(this); } } [NullableContext(0)] private unsafe void AddCurve(ReadOnlySpan<Point> points, float tension) { fixed (Point* points2 = &points.GetPinnableReference()) { PInvokeGdiPlus.GdipAddPathCurve2I(_nativePath, (global::Windows.Win32.Graphics.GdiPlus.Point*)points2, points.Length, tension).ThrowIfFailed(); GC.KeepAlive(this); } } public void AddClosedCurve(params PointF[] points) { AddClosedCurve(points, 0.5); } public void AddClosedCurve(PointF[] points, float tension) { AddClosedCurve(points.OrThrowIfNull("points").AsSpan(), tension); } [NullableContext(0)] private unsafe void AddClosedCurve(ReadOnlySpan<PointF> points, float tension) { fixed (PointF* points2 = &points.GetPinnableReference()) { PInvokeGdiPlus.GdipAddPathClosedCurve2(_nativePath, (global::Windows.Win32.Graphics.GdiPlus.PointF*)points2, points.Length, tension).ThrowIfFailed(); GC.KeepAlive(this); } } public void AddClosedCurve(params Point[] points) { AddClosedCurve(points, 0.5); } public void AddClosedCurve(Point[] points, float tension) { AddClosedCurve(points.OrThrowIfNull("points").AsSpan(), tension); } [NullableContext(0)] private unsafe void AddClosedCurve(ReadOnlySpan<Point> points, float tension) { fixed (Point* points2 = &points.GetPinnableReference()) { PInvokeGdiPlus.GdipAddPathClosedCurve2I(_nativePath, (global::Windows.Win32.Graphics.GdiPlus.Point*)points2, points.Length, tension).ThrowIfFailed(); GC.KeepAlive(this); } } public unsafe void AddRectangle(RectangleF rect) { PInvokeGdiPlus.GdipAddPathRectangle(_nativePath, rect.X, rect.Y, rect.Width, rect.Height).ThrowIfFailed(); GC.KeepAlive(this); } public void AddRectangles(params RectangleF[] rects) { AddRectangles(rects.OrThrowIfNull("rects").AsSpan()); } [NullableContext(0)] private unsafe void AddRectangles([System.Runtime.CompilerServices.ParamCollection] [ScopedRef] ReadOnlySpan<RectangleF> rects) { fixed (RectangleF* rects2 = &rects.GetPinnableReference()) { PInvokeGdiPlus.GdipAddPathRectangles(_nativePath, (RectF*)rects2, rects.Length).ThrowIfFailed(); GC.KeepAlive(this); } } public void AddRectangle(Rectangle rect) { AddRectangle((RectangleF)rect); } public void AddRectangles(params Rectangle[] rects) { AddRectangles(rects.OrThrowIfNull("rects").AsSpan()); } [NullableContext(0)] private unsafe void AddRectangles([System.Runtime.CompilerServices.ParamCollection] [ScopedRef] ReadOnlySpan<Rectangle> rects) { fixed (Rectangle* rects2 = &rects.GetPinnableReference()) { PInvokeGdiPlus.GdipAddPathRectanglesI(_nativePath, (Rect*)rects2, rects.Length).ThrowIfFailed(); GC.KeepAlive(this); } } public void AddEllipse(RectangleF rect) { AddEllipse(rect.X, rect.Y, rect.Width, rect.Height); } public unsafe void AddEllipse(float x, float y, float width, float height) { PInvokeGdiPlus.GdipAddPathEllipse(_nativePath, x, y, width, height).ThrowIfFailed(); GC.KeepAlive(this); } public void AddEllipse(Rectangle rect) { AddEllipse(rect.X, rect.Y, rect.Width, rect.Height); } public void AddEllipse(int x, int y, int width, int height) { AddEllipse((float)x, (float)y, (float)width, (float)height); } public void AddPie(Rectangle rect, float startAngle, float sweepAngle) { AddPie((float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height, startAngle, sweepAngle); } public unsafe void AddPie(float x, float y, float width, float height, float startAngle, float sweepAngle) { PInvokeGdiPlus.GdipAddPathPie(_nativePath, x, y, width, height, startAngle, sweepAngle).ThrowIfFailed(); GC.KeepAlive(this); } public void AddPie(int x, int y, int width, int height, float startAngle, float sweepAngle) { AddPie((float)x, (float)y, (float)width, (float)height, startAngle, sweepAngle); } public void AddPolygon(params PointF[] points) { AddPolygon(points.OrThrowIfNull("points").AsSpan()); } [NullableContext(0)] private unsafe void AddPolygon([System.Runtime.CompilerServices.ParamCollection] [ScopedRef] ReadOnlySpan<PointF> points) { fixed (PointF* points2 = &points.GetPinnableReference()) { PInvokeGdiPlus.GdipAddPathPolygon(_nativePath, (global::Windows.Win32.Graphics.GdiPlus.PointF*)points2, points.Length).ThrowIfFailed(); GC.KeepAlive(this); } } public void AddPolygon(params Point[] points) { AddPolygon(points.OrThrowIfNull("points").AsSpan()); } [NullableContext(0)] private unsafe void AddPolygon([System.Runtime.CompilerServices.ParamCollection] [ScopedRef] ReadOnlySpan<Point> points) { fixed (Point* points2 = &points.GetPinnableReference()) { PInvokeGdiPlus.GdipAddPathPolygonI(_nativePath, (global::Windows.Win32.Graphics.GdiPlus.Point*)points2, points.Length).ThrowIfFailed(); GC.KeepAlive(this); } } public unsafe void AddPath(GraphicsPath addingPath, bool connect) { ArgumentNullException.ThrowIfNull(addingPath, "addingPath"); PInvokeGdiPlus.GdipAddPathPath(_nativePath, addingPath.Pointer(), connect).ThrowIfFailed(); GC.KeepAlive(addingPath); GC.KeepAlive(this); } public void AddString(string s, FontFamily family, int style, float emSize, PointF origin, [Nullable(2)] StringFormat format) { AddString(s, family, style, emSize, new RectangleF(origin.X, origin.Y, 0, 0), format); } public void AddString(string s, FontFamily family, int style, float emSize, Point origin, [Nullable(2)] StringFormat format) { AddString(s, family, style, emSize, new Rectangle(origin.X, origin.Y, 0, 0), format); } public unsafe void AddString(string s, FontFamily family, int style, float emSize, RectangleF layoutRect, [Nullable(2)] StringFormat format) { ArgumentNullException.ThrowIfNull(s, "s"); ArgumentNullException.ThrowIfNull(family, "family"); IntPtr intPtr; if (s == null) intPtr = (IntPtr)(void*)null; else { ref reference = ref s.GetPinnableReference(); intPtr = (IntPtr)(&reference); } char* value = (char*)(long)intPtr; PInvokeGdiPlus.GdipAddPathString(_nativePath, value, s.Length, family.Pointer(), style, emSize, (RectF*)(&layoutRect), format.Pointer()); ref reference = ref *(char*)null; GC.KeepAlive(family); GC.KeepAlive(format); GC.KeepAlive(this); } public void AddString(string s, FontFamily family, int style, float emSize, Rectangle layoutRect, [Nullable(2)] StringFormat format) { AddString(s, family, style, emSize, (RectangleF)layoutRect, format); } public unsafe void Transform(Matrix matrix) { ArgumentNullException.ThrowIfNull(matrix, "matrix"); PInvokeGdiPlus.GdipTransformPath(_nativePath, matrix.NativeMatrix).ThrowIfFailed(); GC.KeepAlive(matrix); GC.KeepAlive(this); } public RectangleF GetBounds() { return GetBounds(null); } [NullableContext(2)] public RectangleF GetBounds(Matrix matrix) { return GetBounds(matrix, null); } [NullableContext(2)] public unsafe RectangleF GetBounds(Matrix matrix, Pen pen) { RectF rect = default(RectF); PInvokeGdiPlus.GdipGetPathWorldBounds(_nativePath, &rect, matrix.Pointer(), pen.Pointer()).ThrowIfFailed(); GC.KeepAlive(this); GC.KeepAlive(matrix); GC.KeepAlive(pen); return rect; } public void Flatten() { Flatten(null); } [NullableContext(2)] public void Flatten(Matrix matrix) { Flatten(matrix, 0.25); } [NullableContext(2)] public unsafe void Flatten(Matrix matrix, float flatness) { PInvokeGdiPlus.GdipFlattenPath(_nativePath, matrix.Pointer(), flatness).ThrowIfFailed(); GC.KeepAlive(this); } public void Widen(Pen pen) { Widen(pen, null, 0.6666667); } public void Widen(Pen pen, [Nullable(2)] Matrix matrix) { Widen(pen, matrix, 0.6666667); } public unsafe void Widen(Pen pen, [Nullable(2)] Matrix matrix, float flatness) { ArgumentNullException.ThrowIfNull(pen, "pen"); if (PointCount != 0) { PInvokeGdiPlus.GdipWidenPath(_nativePath, pen.Pointer(), matrix.Pointer(), flatness).ThrowIfFailed(); GC.KeepAlive(pen); GC.KeepAlive(matrix); GC.KeepAlive(this); } } public void Warp(PointF[] destPoints, RectangleF srcRect) { Warp(destPoints, srcRect, null); } public void Warp(PointF[] destPoints, RectangleF srcRect, [Nullable(2)] Matrix matrix) { Warp(destPoints, srcRect, matrix, WarpMode.Perspective); } public void Warp(PointF[] destPoints, RectangleF srcRect, [Nullable(2)] Matrix matrix, WarpMode warpMode) { Warp(destPoints, srcRect, matrix, warpMode, 0.25); } public void Warp(PointF[] destPoints, RectangleF srcRect, [Nullable(2)] Matrix matrix, WarpMode warpMode, float flatness) { Warp(destPoints.OrThrowIfNull("destPoints").AsSpan(), srcRect, matrix, warpMode, flatness); } [NullableContext(0)] private unsafe void Warp(ReadOnlySpan<PointF> destPoints, RectangleF srcRect, [Nullable(2)] Matrix matrix = null, WarpMode warpMode = WarpMode.Perspective, float flatness = 0.25) { fixed (PointF* points = &destPoints.GetPinnableReference()) { PInvokeGdiPlus.GdipWarpPath(_nativePath, matrix.Pointer(), (global::Windows.Win32.Graphics.GdiPlus.PointF*)points, destPoints.Length, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, (global::Windows.Win32.Graphics.GdiPlus.WarpMode)warpMode, flatness).ThrowIfFailed(); GC.KeepAlive(this); } } [NullableContext(0)] private unsafe int GetPathTypes(Span<byte> destination) { if (!destination.IsEmpty) { fixed (byte* types = &destination.GetPinnableReference()) { PInvokeGdiPlus.GdipGetPathTypes(_nativePath, types, destination.Length).ThrowIfFailed(); GC.KeepAlive(this); return PointCount; } } return 0; } [NullableContext(0)] private unsafe int GetPathPoints(Span<PointF> destination) { if (!destination.IsEmpty) { fixed (PointF* points = &destination.GetPinnableReference()) { PInvokeGdiPlus.GdipGetPathPoints(_nativePath, (global::Windows.Win32.Graphics.GdiPlus.PointF*)points, destination.Length).ThrowIfFailed(); GC.KeepAlive(this); return PointCount; } } return 0; } } }