public VertexStore MakeVxs(VertexStore output) { _reusablePathWriter.Clear(); _reusablePathWriter.NewVxs(); _reusablePathWriter.MoveTo(bounds.Left, bounds.Bottom); _reusablePathWriter.LineTo(bounds.Right, bounds.Bottom); _reusablePathWriter.LineTo(bounds.Right, bounds.Top); _reusablePathWriter.LineTo(bounds.Left, bounds.Top); _reusablePathWriter.CloseFigure(); return(_reusablePathWriter.Vxs); }
public VertexStore MakeVxs() { PathWriter m_LinesToDraw = new PathWriter(); m_LinesToDraw.Clear(); m_LinesToDraw.MoveTo(bounds.Left, bounds.Bottom); m_LinesToDraw.LineTo(bounds.Right, bounds.Bottom); m_LinesToDraw.LineTo(bounds.Right, bounds.Top); m_LinesToDraw.LineTo(bounds.Left, bounds.Top); m_LinesToDraw.CloseFigure(); return(m_LinesToDraw.Vxs); }
protected override void OnMoveTo(short x, short y) { ps.MoveTo(x, y); }
static public int LoadLionData(PathWriter path, PixelFarm.Drawing.Color[] colors, int[] path_idx) { // Parse the lion and then detect its bounding // box and arrange polygons orientations (make all polygons // oriented clockwise or counterclockwise) int npaths = 0; string[] splitOnNL = g_lion.Split('\n'); foreach (string line in splitOnNL) { int newColor; if (line.Length > 0 && line[0] != 'M' && Int32.TryParse(line, NumberStyles.HexNumber, null, out newColor)) { // New color. Every new color creates new path in the path object. path.CloseFigure(); colors[npaths] = PixelFarm.Drawing.Color.CreatRGB8Packed((int)newColor); path_idx[npaths] = path.StartFigure(); npaths++; } else { bool startedPoly = false; string[] splitOnSpace = line.Split(' '); for (int i = 0; i < splitOnSpace.Length; i++) { string[] splitOnComma = splitOnSpace[i].Split(','); if (splitOnComma.Length > 1) { double x = 0.0; double y = 0.0; double.TryParse(splitOnComma[0], NumberStyles.Number, null, out x); double.TryParse(splitOnComma[1], NumberStyles.Number, null, out y); if (!startedPoly) { startedPoly = true; path.CloseFigure(); path.MoveTo(x, y); } else { path.LineTo(x, y); } } } } } //path.ArrangeOrientationsAll(ShapePath.FlagsAndCommand.FlagCW); VertexHelper.ArrangeOrientationsAll(path.Vxs, true); return npaths; }
public static List <VertexStore> CombinePaths(VertexStoreSnap a, VertexStoreSnap b, VxsClipperType vxsClipType, bool separateIntoSmallSubPaths) { //TODO: optimize here ClipType clipType = (ClipType)vxsClipType; List <List <IntPoint> > aPolys = CreatePolygons(a); List <List <IntPoint> > bPolys = CreatePolygons(b); Clipper clipper = new Clipper(); clipper.AddPaths(aPolys, PolyType.ptSubject, true); clipper.AddPaths(bPolys, PolyType.ptClip, true); List <List <IntPoint> > intersectedPolys = new List <List <IntPoint> >(); clipper.Execute(clipType, intersectedPolys); List <VertexStore> resultList = new List <VertexStore>(); PathWriter outputPathWriter = new PathWriter(); if (separateIntoSmallSubPaths) { foreach (List <IntPoint> polygon in intersectedPolys) { int j = polygon.Count; if (j > 0) { //first one IntPoint point = polygon[0]; outputPathWriter.MoveTo(point.X / 1000.0, point.Y / 1000.0); //next others ... if (j > 1) { for (int i = 1; i < j; ++i) { point = polygon[i]; outputPathWriter.LineTo(point.X / 1000.0, point.Y / 1000.0); } } outputPathWriter.CloseFigure(); resultList.Add(outputPathWriter.Vxs); //--- //clear outputPathWriter.ClearAndStartNewVxs(new VertexStore()); } } } else { foreach (List <IntPoint> polygon in intersectedPolys) { int j = polygon.Count; if (j > 0) { //first one IntPoint point = polygon[0]; outputPathWriter.MoveTo(point.X / 1000.0, point.Y / 1000.0); //next others ... if (j > 1) { for (int i = 1; i < j; ++i) { point = polygon[i]; outputPathWriter.LineTo(point.X / 1000.0, point.Y / 1000.0); } } outputPathWriter.CloseFigure(); } } //TODO: review here outputPathWriter.Stop(); resultList.Add(outputPathWriter.Vxs); } return(resultList); }
public static List <VertexStore> CombinePaths(VertexStoreSnap a, VertexStoreSnap b, VxsClipperType vxsClipType, bool separateIntoSmallSubPaths) { ClipType clipType = (ClipType)vxsClipType; List <List <IntPoint> > aPolys = CreatePolygons(a); List <List <IntPoint> > bPolys = CreatePolygons(b); Clipper clipper = new Clipper(); clipper.AddPaths(aPolys, PolyType.ptSubject, true); clipper.AddPaths(bPolys, PolyType.ptClip, true); List <List <IntPoint> > intersectedPolys = new List <List <IntPoint> >(); clipper.Execute(clipType, intersectedPolys); List <VertexStore> resultList = new List <VertexStore>(); PathWriter output = new PathWriter(); if (separateIntoSmallSubPaths) { foreach (List <IntPoint> polygon in intersectedPolys) { int j = polygon.Count; if (j > 0) { //first one IntPoint point = polygon[0]; output.MoveTo(point.X / 1000.0, point.Y / 1000.0); //next others ... if (j > 1) { for (int i = 1; i < j; ++i) { point = polygon[i]; output.LineTo(point.X / 1000.0, point.Y / 1000.0); } } output.CloseFigure(); resultList.Add(output.Vxs); //--- //clear output.ClearAndStartNewVxs(); } } } else { foreach (List <IntPoint> polygon in intersectedPolys) { int j = polygon.Count; if (j > 0) { //first one IntPoint point = polygon[0]; output.MoveTo(point.X / 1000.0, point.Y / 1000.0); //next others ... if (j > 1) { for (int i = 1; i < j; ++i) { point = polygon[i]; output.LineTo(point.X / 1000.0, point.Y / 1000.0); } } output.CloseFigure(); } //bool first = true; //foreach (IntPoint point in polygon) //{ // if (first) // { // output.AddVertex(point.X / 1000.0, point.Y / 1000.0, ShapePath.FlagsAndCommand.CommandMoveTo); // first = false; // } // else // { // output.AddVertex(point.X / 1000.0, point.Y / 1000.0, ShapePath.FlagsAndCommand.CommandLineTo); // } //} } output.Stop(); resultList.Add(output.Vxs); } return(resultList); }
public static List<VertexStore> CombinePaths(VertexStoreSnap a, VertexStoreSnap b, VxsClipperType vxsClipType, bool separateIntoSmallSubPaths) { ClipType clipType = (ClipType)vxsClipType; List<List<IntPoint>> aPolys = CreatePolygons(a); List<List<IntPoint>> bPolys = CreatePolygons(b); Clipper clipper = new Clipper(); clipper.AddPaths(aPolys, PolyType.ptSubject, true); clipper.AddPaths(bPolys, PolyType.ptClip, true); List<List<IntPoint>> intersectedPolys = new List<List<IntPoint>>(); clipper.Execute(clipType, intersectedPolys); List<VertexStore> resultList = new List<VertexStore>(); PathWriter output = new PathWriter(); if (separateIntoSmallSubPaths) { foreach (List<IntPoint> polygon in intersectedPolys) { int j = polygon.Count; if (j > 0) { //first one IntPoint point = polygon[0]; output.MoveTo(point.X / 1000.0, point.Y / 1000.0); //next others ... if (j > 1) { for (int i = 1; i < j; ++i) { point = polygon[i]; output.LineTo(point.X / 1000.0, point.Y / 1000.0); } } output.CloseFigure(); resultList.Add(output.Vxs); //--- //clear output.ClearAndStartNewVxs(new VertexStore()); } } } else { foreach (List<IntPoint> polygon in intersectedPolys) { int j = polygon.Count; if (j > 0) { //first one IntPoint point = polygon[0]; output.MoveTo(point.X / 1000.0, point.Y / 1000.0); //next others ... if (j > 1) { for (int i = 1; i < j; ++i) { point = polygon[i]; output.LineTo(point.X / 1000.0, point.Y / 1000.0); } } output.CloseFigure(); } //bool first = true; //foreach (IntPoint point in polygon) //{ // if (first) // { // output.AddVertex(point.X / 1000.0, point.Y / 1000.0, ShapePath.FlagsAndCommand.CommandMoveTo); // first = false; // } // else // { // output.AddVertex(point.X / 1000.0, point.Y / 1000.0, ShapePath.FlagsAndCommand.CommandLineTo); // } //} } output.Stop(); resultList.Add(output.Vxs); } return resultList; }