public override Region CreateXor(Region another) { CpuBlitRegion rgnB = another as CpuBlitRegion; if (rgnB == null) { return(null); } switch (rgnB.Kind) { default: throw new System.NotSupportedException(); case CpuBlitRegionKind.BitmapBasedRegion: //another is bitmap-based rgn //we need to create bitmap presentation of this vxs rgn //and then send this bitmap to operate with another rgn break; case CpuBlitRegionKind.MixedRegion: break; case CpuBlitRegionKind.VxsRegion: return(new VxsRegion(VxsClipper.CombinePaths(_vxs, ((VxsRegion)another)._vxs, VxsClipperType.Xor, false, null))); } return(null); }
void CreateAndRenderCombined(Painter p, VertexStoreSnap ps1, VertexStoreSnap ps2) { List <VertexStore> combined = null; switch (this.OpOption) { default: throw new NotSupportedException(); case OperationOption.None: return; case OperationOption.OR: combined = VxsClipper.CombinePaths(ps1, ps2, VxsClipperType.Union, false); break; case OperationOption.AND: combined = VxsClipper.CombinePaths(ps1, ps2, VxsClipperType.InterSect, false); break; case OperationOption.XOR: combined = VxsClipper.CombinePaths(ps1, ps2, VxsClipperType.Xor, false); break; case OperationOption.A_B: combined = VxsClipper.CombinePaths(ps1, ps2, VxsClipperType.Difference, false); break; case OperationOption.B_A: combined = VxsClipper.CombinePaths(ps2, ps1, VxsClipperType.Difference, false); break; } if (combined != null) { p.FillColor = ColorEx.Make(0.5f, 0.0f, 0f, 0.5f); p.Fill(new VertexStoreSnap(combined[0])); //graphics2D.Render(new VertexStoreSnap(combined[0]), ColorRGBAf.MakeColorRGBA(0.5f, 0.0f, 0f, 0.5f)); } }
static VertexStore BuildArrow(bool solidHead) { VertexStore arrow; VertexStore stem; using (VectorToolBox.Borrow(out Stroke stroke)) using (VxsTemp.Borrow(out var v1)) using (VxsTemp.Borrow(out var v3, out var v4)) { if (solidHead) { v1.AddMoveTo(5, 20); v1.AddLineTo(10, 10); v1.AddLineTo(15, 20); v1.AddCloseFigure(); arrow = v1.CreateTrim(); BuildLine(10, 20, 10, 50, v3); stem = v3.CreateTrim(); } else { v1.AddMoveTo(5, 20); v1.AddLineTo(10, 10); v1.AddLineTo(15, 20); stroke.LineJoin = LineJoin.Round; stroke.LineCap = LineCap.Round; stroke.Width = 3; arrow = stroke.CreateTrim(v1); BuildLine(10, 10, 10, 50, v3); stem = v3.CreateTrim(); } arrow = VxsClipper.CombinePaths(arrow, stem, VxsClipperType.Union, false, null); return(arrow.ScaleToNewVxs(3, v4).CreateTrim()); } }
public override Region CreateExclude(Region another) { CpuBlitRegion rgnB = another as CpuBlitRegion; if (rgnB == null) { return(null); } switch (rgnB.Kind) { default: throw new System.NotSupportedException(); case CpuBlitRegionKind.BitmapBasedRegion: break; case CpuBlitRegionKind.MixedRegion: break; case CpuBlitRegionKind.VxsRegion: return(new VxsRegion(VxsClipper.CombinePaths(_vxs, ((VxsRegion)another)._vxs, VxsClipperType.Difference, false, null))); } return(null); }