public void AddPathReverse(GraphicsPath path) { for (int i = path.PathActions.Count - 1; i > 0; i--) { PathActions.Add(path.PathActions[i]); } }
public void AddPath(GraphicsPath path) { foreach (var action in path.PathActions) { PathActions.Add(action); } }
public byte[] ToByteArray() { UpdateInt(Team, 14, ref _bytes); UpdateInt(Radius, 12, ref _bytes); // clear all actions UpdateInt(65535, 16, ref _bytes); UpdateInt(65535, 18, ref _bytes); UpdateInt(65535, 20, ref _bytes); UpdateInt(65535, 22, ref _bytes); UpdateInt(65535, 24, ref _bytes); UpdateInt(65535, 26, ref _bytes); // clear all path actions UpdateInt(65535, 28, ref _bytes); UpdateInt(65535, 30, ref _bytes); UpdateInt(65535, 32, ref _bytes); UpdateInt(65535, 34, ref _bytes); UpdateInt(65535, 36, ref _bytes); UpdateInt(65535, 38, ref _bytes); if (Actions.Trim().Length != 0) { string[] actions = Actions.Split(new char[] { ' ' }); int pos = 16; for (int x = 0; x < actions.Length; x++) { try { int action = Convert.ToInt32(actions[x]); UpdateInt(action, pos, ref _bytes); pos += 2; } catch {} } } if (PathActions.Trim().Length != 0) { string[] actions = PathActions.Split(new char[] { ' ' }); int pos = 28; for (int x = 0; x < actions.Length; x++) { try { int action = Convert.ToInt32(actions[x]); UpdateInt(action, pos, ref _bytes); pos += 2; } catch {} } } return(_bytes); }
public void Close() { if (PathActions.Count == 0) { return; } PathActions.Add(new PathAction(GetPathStart().PathPoint, VerbType.Close)); }
public void LineTo(Point point) { if (PathActions.Count == 0) { MoveTo(point); return; } PathActions.Add(new PathAction(point, VerbType.Line)); }
public void LineTo(int x, int y) { if (PathActions.Count == 0) { MoveTo(x, y); return; } PathActions.Add(new PathAction(new Point(x, y), VerbType.Line)); }
public void RelativeLineTo(Point point) { int count = PathActions.Count; if (count > 0) { PathActions.Add(new PathAction(point + ((PathAction)PathActions[count - 1]).PathPoint, VerbType.Line)); } else { LineTo(point); } }
public void RelativeLineTo(int x, int y) { int count = PathActions.Count; if (count > 0) { PathActions.Add(new PathAction(new Point(x, y) + ((PathAction)PathActions[count - 1]).PathPoint, VerbType.Line)); } else { LineTo(x, y); } }
public void RelativeMoveTo(Point point) { int count = PathActions.Count; if (count > 0) { PathActions.Add(new PathAction(point + PathActions[count - 1].PathPoint, VerbType.Move)); } else { MoveTo(point); } }
public void RelativeMoveTo(int x, int y) { int count = PathActions.Count; if (count > 0) { PathActions.Add(new PathAction(new Point(x, y) + PathActions[count - 1].PathPoint, VerbType.Move)); } else { MoveTo(x, y); } }
public void MoveTo(Point point) { if (PathActions.Count > 0) { var last = GetLastAction(); if (last.Verb == VerbType.Move) { last.PathPoint = point; return; } } PathActions.Add(new PathAction(point, VerbType.Move)); }
PathAction GetPathStart() { var action = PathActions.Where(p => p.Verb == VerbType.Close).LastOrDefault(); if (action.Verb == VerbType.Close) { var index = PathActions.IndexOf(action); if (index < PathActions.Count - 1 && PathActions[index + 1].Verb == VerbType.Move) { index++; } return(PathActions[index]); } return(PathActions[0]); }
PathAction GetPathStart() { //var action = PathActions.Where(p => p.Verb == VerbType.Close).LastOrDefault(); PathAction action = default; for (var i = PathActions.Count - 1; i >= 0; i--) { action = (PathAction)PathActions[i]; break; } if (action.Verb == VerbType.Close) { var index = PathActions.IndexOf(action); if (index < PathActions.Count - 1 && ((PathAction)PathActions[index + 1]).Verb == VerbType.Move) { index++; } return((PathAction)PathActions[index]); } return((PathAction)PathActions[0]); }
List <Path> extractSubpaths(List <PAction> inActions) { // not use yet Debug.LogError("extractSubpaths not implement"); List <Path> subPaths = new List <Path> (); Path lastPath = new Path(); for (int i = 0, il = inActions.Count; i < il; i++) { PAction item = inActions [i]; List <float> args = item.args; PathActions action = item.action; bool aClockwise = item.aClockwise; if (action == PathActions.MOVE_TO) { if (lastPath.actions.Count != 0) { subPaths.Add(lastPath); lastPath = new Path(); } } // js 477 //lastPath[ action ].apply( lastPath, args ); Debug.LogError("######### TODO: no implement ############"); if (action == PathActions.MOVE_TO) { lastPath.moveTo(args [0], args [1]); } else if (action == PathActions.LINE_TO) { lastPath.lineTo(args [0], args [1]); } else if (action == PathActions.ARC) { //lastPath.arc(args[0], args[1], args[2], args[3], args[4], args[5]); } else if (action == PathActions.ELLIPSE) { lastPath.ellipse(args [0], args [1], args [2], args [3], args [4], args [5], aClockwise); } else if (action == PathActions.QUADRATIC_CURVE_TO) { lastPath.quadraticCurveTo(args [0], args [1], args [2], args [3]); } else { } } if (lastPath.actions.Count != 0) { subPaths.Add(lastPath); } // console.log(subPaths); return(subPaths); }
public PAction(PathActions action, List <float> pos) { this.action = action; this.args = pos; }
PathAction GetLastAction() { return(PathActions.Last()); }