public static PdnGraphicsPath FromRegion(PdnRegion region) { Rectangle bounds = region.GetBoundsInt(); Rectangle[] scans = region.GetRegionScansReadOnlyInt(); BitVector2D 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 (Matrix 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); BitVector2D 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 (Matrix 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); BitVector2D 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 (Matrix matrix = new Matrix()) { matrix.Reset(); matrix.Translate(bounds.X, bounds.Y); path.Transform(matrix); } return path; }
public static PdnGraphicsPath FromRegion(PdnRegion region) { Rectangle[] scans = region.GetRegionScansReadOnlyInt(); if (scans.Length == 1) { PdnGraphicsPath path = new PdnGraphicsPath(); path.AddRectangle(scans[0]); path.CloseFigure(); return path; } else { Rectangle bounds = region.GetBoundsInt(); BitVector2D 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 (Matrix matrix = new Matrix()) { matrix.Reset(); matrix.Translate(bounds.X, bounds.Y); path.Transform(matrix); } return path; } }