/src/Core/PdnGraphicsPath.cs
C# | 1206 lines | 962 code | 198 blank | 46 comment | 80 complexity | b88b712abdd2593ec254a42522a761cf MD5 | raw file
- /////////////////////////////////////////////////////////////////////////////////
- // Paint.NET //
- // Copyright (C) dotPDN LLC, Rick Brewster, Tom Jackson, and contributors. //
- // Portions Copyright (C) Microsoft Corporation. All Rights Reserved. //
- // See src/Resources/Files/License.txt for full licensing and attribution //
- // details. //
- // . //
- /////////////////////////////////////////////////////////////////////////////////
-
- using PaintDotNet.Base;
- using PaintDotNet.SystemLayer;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Runtime.Serialization;
-
- namespace PaintDotNet
- {
- [Serializable]
- public sealed class PdnGraphicsPath
- : MarshalByRefObject,
- ICloneable,
- IDisposable,
- ISerializable
- {
- private GraphicsPath _gdiPath;
- private bool _tooComplex;
- internal PdnRegion RegionCache;
-
- public static implicit operator GraphicsPath(PdnGraphicsPath convert)
- {
- return convert._gdiPath;
- }
-
- internal PdnRegion GetRegionCache()
- {
- return RegionCache ?? (RegionCache = new PdnRegion(_gdiPath));
- }
-
- /*
- private GraphicsPath GdiPath
- {
- get
- {
- return _gdiPath;
- }
- }
- */ //SUSPECTED UNUSED PROPERTY
-
- private void Changed()
- {
- if (RegionCache == null) return;
- lock (RegionCache.SyncRoot)
- {
- RegionCache.Dispose();
- RegionCache = null;
- }
- }
-
- public PdnGraphicsPath()
- {
- Changed();
- _gdiPath = new GraphicsPath();
- }
-
- public PdnGraphicsPath(GraphicsPath wrapMe)
- {
- Changed();
- _gdiPath = wrapMe;
- }
-
- public PdnGraphicsPath(FillMode fillMode)
- {
- Changed();
- _gdiPath = new GraphicsPath(fillMode);
- }
-
- public PdnGraphicsPath(Point[] pts, byte[] types)
- {
- Changed();
- _gdiPath = new GraphicsPath(pts, types);
- }
-
- public PdnGraphicsPath(PointF[] pts, byte[] types)
- {
- Changed();
- _gdiPath = new GraphicsPath(pts, types);
- }
-
- public PdnGraphicsPath(Point[] pts, byte[] types, FillMode fillMode)
- {
- Changed();
- _gdiPath = new GraphicsPath(pts, types, fillMode);
- }
-
- public PdnGraphicsPath(PointF[] pts, byte[] types, FillMode fillMode)
- {
- Changed();
- _gdiPath = new GraphicsPath(pts, types, fillMode);
- }
-
- public PdnGraphicsPath(SerializationInfo info, StreamingContext context)
- {
- int ptCount = info.GetInt32("ptCount");
-
- PointF[] pts;
- byte[] types;
-
- if (ptCount == 0)
- {
- pts = new PointF[0];
- types = new byte[0];
- }
- else
- {
- pts = (PointF[])info.GetValue("pts", typeof(PointF[]));
- types = (byte[])info.GetValue("types", typeof(byte[]));
- }
-
- var fillMode = (FillMode)info.GetValue("fillMode", typeof(FillMode));
- Changed();
-
- _gdiPath = ptCount == 0 ? new GraphicsPath() : new GraphicsPath(pts, types, fillMode);
-
- _tooComplex = false;
- RegionCache = null;
- }
-
- public void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- lock (this) // avoid race condition with Dispose()
- {
- info.AddValue("ptCount", _gdiPath.PointCount);
-
- if (_gdiPath.PointCount > 0)
- {
- info.AddValue("pts", _gdiPath.PathPoints);
- info.AddValue("types", _gdiPath.PathTypes);
- }
-
- info.AddValue("fillMode", _gdiPath.FillMode);
- }
- }
-
- public static PdnGraphicsPath FromRegion(PdnRegion region)
- {
- Rectangle[] scans = region.GetRegionScansReadOnlyInt();
-
- if (scans.Length == 1)
- {
- var path = new PdnGraphicsPath();
- path.AddRectangle(scans[0]);
- path.CloseFigure();
- return path;
- }
- else
- {
- Rectangle bounds = region.GetBoundsInt();
- var stencil = new BitVector2D(bounds.Width, bounds.Height);
-
- for (int i = 0; i < scans.Length; ++i)
- {
- Rectangle rect = scans[i];
- rect.X -= bounds.X;
- rect.Y -= bounds.Y;
-
- stencil.SetUnchecked(rect, true);
- }
-
- PdnGraphicsPath path = PathFromStencil(stencil, new Rectangle(0, 0, stencil.Width, stencil.Height));
-
- using (var matrix = new Matrix())
- {
- matrix.Reset();
- matrix.Translate(bounds.X, bounds.Y);
- path.Transform(matrix);
- }
-
- return path;
- }
- }
-
- public static PdnGraphicsPath FromRegions(PdnRegion lhs, CombineMode combineMode, PdnRegion rhs)
- {
- Rectangle lhsBounds = lhs.GetBoundsInt();
- Rectangle rhsBounds = rhs.GetBoundsInt();
- int left = Math.Min(lhsBounds.Left, rhsBounds.Left);
- int top = Math.Min(lhsBounds.Top, rhsBounds.Top);
- int right = Math.Max(lhsBounds.Right, rhsBounds.Right);
- int bottom = Math.Max(lhsBounds.Bottom, rhsBounds.Bottom);
- Rectangle bounds = Rectangle.FromLTRB(left, top, right, bottom);
- var stencil = new BitVector2D(bounds.Width, bounds.Height);
- Rectangle[] lhsScans = lhs.GetRegionScansReadOnlyInt();
- Rectangle[] rhsScans = rhs.GetRegionScansReadOnlyInt();
-
- switch (combineMode)
- {
- case CombineMode.Complement:
- case CombineMode.Intersect:
- case CombineMode.Replace:
- throw new ArgumentException("combineMode can't be Complement, Intersect, or Replace");
-
- default:
- break;
- }
-
- for (int i = 0; i < lhsScans.Length; ++i)
- {
- Rectangle rect = lhsScans[i];
- rect.X -= bounds.X;
- rect.Y -= bounds.Y;
-
- stencil.SetUnchecked(rect, true);
- }
-
- for (int i = 0; i < rhsScans.Length; ++i)
- {
- Rectangle rect = rhsScans[i];
- rect.X -= bounds.X;
- rect.Y -= bounds.Y;
-
- switch (combineMode)
- {
- case CombineMode.Xor:
- stencil.InvertUnchecked(rect);
- break;
-
- case CombineMode.Union:
- stencil.SetUnchecked(rect, true);
- break;
-
- case CombineMode.Exclude:
- stencil.SetUnchecked(rect, false);
- break;
- }
- }
-
- PdnGraphicsPath path = PathFromStencil(stencil, new Rectangle(0, 0, stencil.Width, stencil.Height));
-
- using (var matrix = new Matrix())
- {
- matrix.Reset();
- matrix.Translate(bounds.X, bounds.Y);
- path.Transform(matrix);
- }
-
- return path;
- }
-
- public static Point[][] PolygonSetFromStencil(IBitVector2D stencil, Rectangle bounds, int translateX, int translateY)
- {
- var polygons = new List<Point[]>();
-
- if (!stencil.IsEmpty)
- {
- Point start = bounds.Location;
- var pts = new List<Point>();
- int count = 0;
-
- // find all islands
- while (true)
- {
- bool startFound = false;
-
- while (true)
- {
- if (stencil[start])
- {
- startFound = true;
- break;
- }
-
- ++start.X;
-
- if (start.X < bounds.Right) continue;
- ++start.Y;
- start.X = bounds.Left;
-
- if (start.Y >= bounds.Bottom)
- {
- break;
- }
- }
-
- if (!startFound)
- {
- break;
- }
-
- pts.Clear();
- var last = new Point(start.X, start.Y + 1);
- var curr = new Point(start.X, start.Y);
- Point next = curr;
- Point left = Point.Empty;
- Point right = Point.Empty;
-
- // trace island outline
- while (true)
- {
- left.X = ((curr.X - last.X) + (curr.Y - last.Y) + 2) / 2 + curr.X - 1;
- left.Y = ((curr.Y - last.Y) - (curr.X - last.X) + 2) / 2 + curr.Y - 1;
-
- right.X = ((curr.X - last.X) - (curr.Y - last.Y) + 2) / 2 + curr.X - 1;
- right.Y = ((curr.Y - last.Y) + (curr.X - last.X) + 2) / 2 + curr.Y - 1;
-
- if (bounds.Contains(left) && stencil[left])
- {
- // go left
- next.X += curr.Y - last.Y;
- next.Y -= curr.X - last.X;
- }
- else if (bounds.Contains(right) && stencil[right])
- {
- // go straight
- next.X += curr.X - last.X;
- next.Y += curr.Y - last.Y;
- }
- else
- {
- // turn right
- next.X -= curr.Y - last.Y;
- next.Y += curr.X - last.X;
- }
-
- if (Math.Sign(next.X - curr.X) != Math.Sign(curr.X - last.X) ||
- Math.Sign(next.Y - curr.Y) != Math.Sign(curr.Y - last.Y))
- {
- pts.Add(curr);
- ++count;
- }
-
- last = curr;
- curr = next;
-
- if (next.X == start.X && next.Y == start.Y)
- {
- break;
- }
- }
-
- Point[] points = pts.ToArray();
- Scanline[] scans = Utility.GetScans(points);
-
- foreach (Scanline scan in scans)
- {
- stencil.Invert(scan);
- }
-
- Utility.TranslatePointsInPlace(points, translateX, translateY);
- polygons.Add(points);
- }
- }
-
- Point[][] returnVal = polygons.ToArray();
- return returnVal;
- }
-
- /// <summary>
- /// Creates a graphics path from the given stencil buffer. It should be filled with 'true' values
- /// to indicate the areas that should be outlined.
- /// </summary>
- /// <param name="stencil">The stencil buffer to read from. NOTE: The contents of this will be destroyed when this method returns.</param>
- /// <param name="bounds">The bounding box within the stencil buffer to limit discovery to.</param>
- /// <returns>A PdnGraphicsPath with traces that outline the various areas from the given stencil buffer.</returns>
- public static PdnGraphicsPath PathFromStencil(IBitVector2D stencil, Rectangle bounds)
- {
- if (stencil.IsEmpty)
- {
- return new PdnGraphicsPath();
- }
-
- var ret = new PdnGraphicsPath();
- Point start = bounds.Location;
- var pts = new Vector<Point>();
- int count = 0;
-
- // find all islands
- while (true)
- {
- bool startFound = false;
-
- while (true)
- {
- if (stencil[start])
- {
- startFound = true;
- break;
- }
-
- ++start.X;
-
- if (start.X < bounds.Right) continue;
- ++start.Y;
- start.X = bounds.Left;
-
- if (start.Y >= bounds.Bottom)
- {
- break;
- }
- }
-
- if (!startFound)
- {
- break;
- }
-
- pts.Clear();
- var last = new Point(start.X, start.Y + 1);
- var curr = new Point(start.X, start.Y);
- Point next = curr;
- Point left = Point.Empty;
- Point right = Point.Empty;
-
- // trace island outline
- while (true)
- {
- left.X = ((curr.X - last.X) + (curr.Y - last.Y) + 2) / 2 + curr.X - 1;
- left.Y = ((curr.Y - last.Y) - (curr.X - last.X) + 2) / 2 + curr.Y - 1;
-
- right.X = ((curr.X - last.X) - (curr.Y - last.Y) + 2) / 2 + curr.X - 1;
- right.Y = ((curr.Y - last.Y) + (curr.X - last.X) + 2) / 2 + curr.Y - 1;
-
- if (bounds.Contains(left) && stencil[left])
- {
- // go left
- next.X += curr.Y - last.Y;
- next.Y -= curr.X - last.X;
- }
- else if (bounds.Contains(right) && stencil[right])
- {
- // go straight
- next.X += curr.X - last.X;
- next.Y += curr.Y - last.Y;
- }
- else
- {
- // turn right
- next.X -= curr.Y - last.Y;
- next.Y += curr.X - last.X;
- }
-
- if (Math.Sign(next.X - curr.X) != Math.Sign(curr.X - last.X) ||
- Math.Sign(next.Y - curr.Y) != Math.Sign(curr.Y - last.Y))
- {
- pts.Add(curr);
- ++count;
- }
-
- last = curr;
- curr = next;
-
- if (next.X == start.X && next.Y == start.Y)
- {
- break;
- }
- }
-
- Point[] points = pts.ToArray();
- Scanline[] scans = Utility.GetScans(points);
-
- foreach (Scanline scan in scans)
- {
- stencil.Invert(scan);
- }
-
- ret.AddLines(points);
- ret.CloseFigure();
- }
-
- return ret;
- }
-
- public static PdnGraphicsPath Combine(PdnGraphicsPath subjectPath, CombineMode combineMode, PdnGraphicsPath clipPath)
- {
- switch (combineMode)
- {
- case CombineMode.Complement:
- return Combine(clipPath, CombineMode.Exclude, subjectPath);
-
- case CombineMode.Replace:
- return clipPath.Clone();
-
- case CombineMode.Xor:
- case CombineMode.Intersect:
- case CombineMode.Union:
- case CombineMode.Exclude:
- if (subjectPath.IsEmpty && clipPath.IsEmpty)
- {
- return new PdnGraphicsPath(); // empty path
- }
- if (subjectPath.IsEmpty)
- {
- switch (combineMode)
- {
- case CombineMode.Xor:
- case CombineMode.Union:
- return clipPath.Clone();
-
- case CombineMode.Intersect:
- case CombineMode.Exclude:
- return new PdnGraphicsPath();
-
- default:
- throw new InvalidEnumArgumentException();
- }
- }
- if (clipPath.IsEmpty)
- {
- switch (combineMode)
- {
- case CombineMode.Exclude:
- case CombineMode.Xor:
- case CombineMode.Union:
- return subjectPath.Clone();
-
- case CombineMode.Intersect:
- return new PdnGraphicsPath();
-
- default:
- throw new InvalidEnumArgumentException();
- }
- }
- GraphicsPath resultPath = PdnGraphics.ClipPath(subjectPath, combineMode, clipPath);
- return new PdnGraphicsPath(resultPath);
-
- default:
- throw new InvalidEnumArgumentException();
- }
- }
-
-
- ~PdnGraphicsPath()
- {
- Changed();
- Dispose(false);
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
- if (!disposing) return;
- lock (this) // avoid race condition with GetObjectData()
- {
- if (_gdiPath != null)
- {
- _gdiPath.Dispose();
- _gdiPath = null;
- }
-
- if (RegionCache == null) return;
- RegionCache.Dispose();
- RegionCache = null;
- }
- }
-
- public FillMode FillMode
- {
- get
- {
- return _gdiPath.FillMode;
- }
-
- set
- {
- Changed();
- _gdiPath.FillMode = value;
- }
- }
-
- public PathData PathData
- {
- get
- {
- return _gdiPath.PathData;
- }
- }
-
- public PointF[] PathPoints
- {
- get
- {
- return _gdiPath.PathPoints;
- }
- }
-
- public byte[] PathTypes
- {
- get
- {
- return _gdiPath.PathTypes;
- }
- }
-
- public int PointCount
- {
- get
- {
- return _gdiPath.PointCount;
- }
- }
-
- public void AddArc(Rectangle rect, float startAngle, float sweepAngle)
- {
- Changed();
- _gdiPath.AddArc(rect, startAngle, sweepAngle);
- }
-
- public void AddArc(RectangleF rectF, float startAngle, float sweepAngle)
- {
- Changed();
- _gdiPath.AddArc(rectF, startAngle, sweepAngle);
- }
-
- public void AddArc(int x, int y, int width, int height, float startAngle, float sweepAngle)
- {
- Changed();
- _gdiPath.AddArc(x, y, width, height, startAngle, sweepAngle);
- }
-
- public void AddArc(float x, float y, float width, float height, float startAngle, float sweepAngle)
- {
- Changed();
- _gdiPath.AddArc(x, y, width, height, startAngle, sweepAngle);
- }
-
- public void AddBezier(Point pt1, Point pt2, Point pt3, Point pt4)
- {
- Changed();
- _gdiPath.AddBezier(pt1, pt2, pt3, pt4);
- }
-
- public void AddBezier(PointF pt1, PointF pt2, PointF pt3, PointF pt4)
- {
- Changed();
- _gdiPath.AddBezier(pt1, pt2, pt3, pt4);
- }
-
- public void AddBezier(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
- {
- Changed();
- _gdiPath.AddBezier(x1, y1, x2, y2, x3, y3, x4, y4);
- }
-
- public void AddBezier(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
- {
- Changed();
- _gdiPath.AddBezier(x1, y1, x2, y2, x3, y3, x4, y4);
- }
-
- public void AddBeziers(Point[] points)
- {
- Changed();
- _gdiPath.AddBeziers(points);
- }
-
- public void AddBeziers(PointF[] points)
- {
- Changed();
- _gdiPath.AddBeziers(points);
- }
-
- public void AddClosedCurve(Point[] points)
- {
- Changed();
- _gdiPath.AddClosedCurve(points);
- }
-
- public void AddClosedCurve(PointF[] points)
- {
- Changed();
- _gdiPath.AddClosedCurve(points);
- }
-
- public void AddClosedCurve(Point[] points, float tension)
- {
- Changed();
- _gdiPath.AddClosedCurve(points, tension);
- }
-
- public void AddClosedCurve(PointF[] points, float tension)
- {
- Changed();
- _gdiPath.AddClosedCurve(points, tension);
- }
-
- public void AddCurve(Point[] points)
- {
- Changed();
- _gdiPath.AddCurve(points);
- }
-
- public void AddCurve(PointF[] points)
- {
- Changed();
- _gdiPath.AddCurve(points);
- }
-
- public void AddCurve(Point[] points, float tension)
- {
- Changed();
- _gdiPath.AddCurve(points, tension);
- }
-
- public void AddCurve(PointF[] points, float tension)
- {
- Changed();
- _gdiPath.AddCurve(points, tension);
- }
-
- public void AddCurve(Point[] points, int offset, int numberOfSegments, float tension)
- {
- Changed();
- _gdiPath.AddCurve(points, offset, numberOfSegments, tension);
- }
-
- public void AddCurve(PointF[] points, int offset, int numberOfSegments, float tension)
- {
- Changed();
- _gdiPath.AddCurve(points, offset, numberOfSegments, tension);
- }
-
- public void AddEllipse(Rectangle rect)
- {
- Changed();
- _gdiPath.AddEllipse(rect);
- }
-
- public void AddEllipse(RectangleF rectF)
- {
- Changed();
- _gdiPath.AddEllipse(rectF);
- }
-
- public void AddEllipse(int x, int y, int width, int height)
- {
- Changed();
- _gdiPath.AddEllipse(x, y, width, height);
- }
-
- public void AddEllipse(float x, float y, float width, float height)
- {
- Changed();
- _gdiPath.AddEllipse(x, y, width, height);
- }
-
- public void AddLine(Point pt1, Point pt2)
- {
- Changed();
- _gdiPath.AddLine(pt1, pt2);
- }
-
- public void AddLine(PointF pt1, PointF pt2)
- {
- Changed();
- _gdiPath.AddLine(pt1, pt2);
- }
-
- public void AddLine(int x1, int y1, int x2, int y2)
- {
- Changed();
- _gdiPath.AddLine(x1, y1, x2, y2);
- }
-
- public void AddLine(float x1, float y1, float x2, float y2)
- {
- Changed();
- _gdiPath.AddLine(x1, y1, x2, y2);
- }
-
- public void AddLines(Point[] points)
- {
- Changed();
- _gdiPath.AddLines(points);
- }
-
- public void AddLines(PointF[] points)
- {
- Changed();
- _gdiPath.AddLines(points);
- }
-
- public void AddPath(GraphicsPath addingPath, bool connect)
- {
- if (addingPath.PointCount == 0) return;
- Changed();
- _gdiPath.AddPath(addingPath, connect);
- }
-
- public void AddPie(Rectangle rect, float startAngle, float sweepAngle)
- {
- Changed();
- _gdiPath.AddPie(rect, startAngle, sweepAngle);
- }
-
- public void AddPie(int x, int y, int width, int height, float startAngle, float sweepAngle)
- {
- Changed();
- _gdiPath.AddPie(x, y, width, height, startAngle, sweepAngle);
- }
-
- public void AddPie(float x, float y, float width, float height, float startAngle, float sweepAngle)
- {
- Changed();
- _gdiPath.AddPie(x, y, width, height, startAngle, sweepAngle);
- }
-
- public void AddPolygon(Point[] points)
- {
- Changed();
- _gdiPath.AddPolygon(points);
- }
-
- public void AddPolygon(PointF[] points)
- {
- Changed();
- _gdiPath.AddPolygon(points);
- }
-
- public void AddPolygons(PointF[][] polygons)
- {
- foreach (PointF[] polygon in polygons)
- {
- AddPolygon(polygon);
- CloseFigure();
- }
- }
-
- public void AddPolygons(Point[][] polygons)
- {
- foreach (Point[] polygon in polygons)
- {
- AddPolygon(polygon);
- CloseFigure();
- }
- }
-
- public void AddRectangle(Rectangle rect)
- {
- Changed();
- _gdiPath.AddRectangle(rect);
- }
-
- public void AddRectangle(RectangleF rectF)
- {
- Changed();
- _gdiPath.AddRectangle(rectF);
- }
-
- public void AddRectangles(Rectangle[] rects)
- {
- Changed();
- _gdiPath.AddRectangles(rects);
- }
-
- public void AddRectangles(RectangleF[] rectsF)
- {
- Changed();
- _gdiPath.AddRectangles(rectsF);
- }
-
- public void AddString(string s, FontFamily family, int style, float emSize, Point origin, StringFormat format)
- {
- Changed();
- _gdiPath.AddString(s, family, style, emSize, origin, format);
- }
-
- public void AddString(string s, FontFamily family, int style, float emSize, PointF origin, StringFormat format)
- {
- Changed();
- _gdiPath.AddString(s, family, style, emSize, origin, format);
- }
-
- public void AddString(string s, FontFamily family, int style, float emSize, Rectangle layoutRect, StringFormat format)
- {
- Changed();
- _gdiPath.AddString(s, family, style, emSize, layoutRect, format);
- }
-
- public void AddString(string s, FontFamily family, int style, float emSize, RectangleF layoutRect, StringFormat format)
- {
- Changed();
- _gdiPath.AddString(s, family, style, emSize, layoutRect, format);
- }
-
- public void ClearMarkers()
- {
- Changed();
- _gdiPath.ClearMarkers();
- }
-
- object ICloneable.Clone()
- {
- return Clone();
- }
-
- public PdnGraphicsPath Clone()
- {
- var path = new PdnGraphicsPath((GraphicsPath)_gdiPath.Clone()) {_tooComplex = _tooComplex};
- return path;
- }
-
- public void CloseAllFigures()
- {
- Changed();
- _gdiPath.CloseAllFigures();
- }
-
- public void CloseFigure()
- {
- Changed();
- _gdiPath.CloseFigure();
- }
-
- public void Draw(Graphics g, Pen pen)
- {
- Draw(g, pen, false);
- }
-
- /// <summary>
- /// Draws the path to the given Graphics context using the given Pen.
- /// </summary>
- /// <param name="g">The Graphics context to draw to.</param>
- /// <param name="pen">The Pen to draw with.</param>
- /// <param name="presentationIntent">
- /// If true, gives a hint that the path is being drawn to be presented to the user.
- /// </param>
- /// <remarks>
- /// If the path is "too complex," and if presentationIntent is true, then the path will
- /// not be drawn. To force the path to be drawn, set presentationIntent to false.
- /// </remarks>
- public void Draw(Graphics g, Pen pen, bool presentationIntent)
- {
- try
- {
- if (!_tooComplex || !presentationIntent)
- {
- int start = Environment.TickCount;
- g.DrawPath(pen, _gdiPath);
- int end = Environment.TickCount;
-
- if ((end - start) > 1000)
- {
- _tooComplex = true;
- }
- }
- }
-
- catch (OutOfMemoryException ex)
- {
- _tooComplex = true;
- Tracing.Ping("DrawPath exception: " + ex);
- }
- }
-
- public void Flatten()
- {
- Changed();
- _gdiPath.Flatten();
- }
-
- public void Flatten(Matrix matrix)
- {
- Changed();
- _gdiPath.Flatten(matrix);
- }
-
- public void Flatten(Matrix matrix, float flatness)
- {
- Changed();
- _gdiPath.Flatten(matrix, flatness);
- }
-
- public RectangleF GetBounds2()
- {
- if (PointCount == 0)
- {
- return RectangleF.Empty;
- }
-
- PointF[] points = PathPoints;
-
- if (points.Length == 0)
- {
- return RectangleF.Empty;
- }
-
- float left = points[0].X;
- float right = points[0].X;
- float top = points[0].Y;
- float bottom = points[0].Y;
-
- for (int i = 1; i < points.Length; ++i)
- {
- if (points[i].X < left)
- {
- left = points[i].X;
- }
-
- if (points[i].Y < top)
- {
- top = points[i].Y;
- }
-
- if (points[i].X > right)
- {
- right = points[i].X;
- }
-
- if (points[i].Y > bottom)
- {
- bottom = points[i].Y;
- }
- }
-
- return RectangleF.FromLTRB(left, top, right, bottom);
- }
-
- public RectangleF GetBounds()
- {
- return _gdiPath.GetBounds();
- }
-
- public RectangleF GetBounds(Matrix matrix)
- {
- return _gdiPath.GetBounds(matrix);
- }
-
- public RectangleF GetBounds(Matrix matrix, Pen pen)
- {
- return _gdiPath.GetBounds(matrix, pen);
- }
-
- public PointF GetLastPoint()
- {
- return _gdiPath.GetLastPoint();
- }
-
- public bool IsEmpty
- {
- get
- {
- return PointCount == 0;
- }
- }
-
- public bool IsOutlineVisible(Point point, Pen pen)
- {
- return _gdiPath.IsOutlineVisible(point, pen);
- }
-
- public bool IsOutlineVisible(PointF point, Pen pen)
- {
- return _gdiPath.IsOutlineVisible(point, pen);
- }
-
- public bool IsOutlineVisible(int x, int y, Pen pen)
- {
- return _gdiPath.IsOutlineVisible(x, y, pen);
- }
-
- public bool IsOutlineVisible(Point point, Pen pen, Graphics g)
- {
- return _gdiPath.IsOutlineVisible(point, pen, g);
- }
-
- public bool IsOutlineVisible(PointF point, Pen pen, Graphics g)
- {
- return _gdiPath.IsOutlineVisible(point, pen, g);
- }
-
- public bool IsOutlineVisible(float x, float y, Pen pen)
- {
- return _gdiPath.IsOutlineVisible(x, y, pen);
- }
-
- public bool IsOutlineVisible(int x, int y, Pen pen, Graphics g)
- {
- return _gdiPath.IsOutlineVisible(x, y, pen, g);
- }
-
- public bool IsOutlineVisible(float x, float y, Pen pen, Graphics g)
- {
- return _gdiPath.IsOutlineVisible(x, y, pen, g);
- }
-
- public bool IsVisible(Point point)
- {
- return _gdiPath.IsVisible(point);
- }
-
- public bool IsVisible(PointF point)
- {
- return _gdiPath.IsVisible(point);
- }
-
- public bool IsVisible(int x, int y)
- {
- return _gdiPath.IsVisible(x, y);
- }
-
- public bool IsVisible(Point point, Graphics g)
- {
- return _gdiPath.IsVisible(point, g);
- }
-
- public bool IsVisible(PointF point, Graphics g)
- {
- return _gdiPath.IsVisible(point, g);
- }
-
- public bool IsVisible(float x, float y)
- {
- return _gdiPath.IsVisible(x, y);
- }
-
- public bool IsVisible(int x, int y, Graphics g)
- {
- return _gdiPath.IsVisible(x, y, g);
- }
-
- public bool IsVisible(float x, float y, Graphics g)
- {
- return _gdiPath.IsVisible(x, y, g);
- }
-
- public void Reset()
- {
- Changed();
- _tooComplex = false;
- _gdiPath.Reset();
- }
-
- public void Reverse()
- {
- Changed();
- _gdiPath.Reverse();
- }
-
- public void SetMarkers()
- {
- Changed();
- _gdiPath.SetMarkers();
- }
-
- public void StartFigure()
- {
- Changed();
- _gdiPath.StartFigure();
- }
-
- public void Transform(Matrix matrix)
- {
- Changed();
- _gdiPath.Transform(matrix);
- }
-
- public void Warp(PointF[] destPoints, RectangleF srcRect)
- {
- Changed();
- _gdiPath.Warp(destPoints, srcRect);
- }
-
- public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix)
- {
- Changed();
- _gdiPath.Warp(destPoints, srcRect, matrix);
- }
-
- public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode)
- {
- Changed();
- _gdiPath.Warp(destPoints, srcRect, matrix, warpMode);
- }
-
- public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode, float flatness)
- {
- Changed();
- _gdiPath.Warp(destPoints, srcRect, matrix, warpMode, flatness);
- }
-
- public void Widen(Pen pen)
- {
- Changed();
- _gdiPath.Widen(pen);
- }
-
- public void Widen(Pen pen, Matrix matrix)
- {
- Changed();
- _gdiPath.Widen(pen, matrix);
- }
-
- public void Widen(Pen pen, Matrix matrix, float flatness)
- {
- Changed();
- _gdiPath.Widen(pen, matrix, flatness);
- }
- }
- }