private void DrawShape(Vex.Shape sh) { List <GraphicsPath> paths; if (sh.Fill != null && fillOverride != Brushes.Transparent) { paths = GetPath(sh.ShapeData, true); FillPaths(sh.Fill, paths); } if (sh.Stroke != null) { if (penOverride != Pens.Transparent) { paths = GetPath(sh.ShapeData, false); StrokePaths(sh.Stroke, paths); } } else { // this gets rid of slight aliasing spaces between touching vectors // todo: do average colors for gradients or something. if (sh.Fill.FillType == Vex.FillType.Solid) { Vex.StrokeStyle ss = new Vex.SolidStroke(.1F, ((Vex.SolidFill)sh.Fill).Color); paths = GetPath(sh.ShapeData, false); StrokePaths(ss, paths); } } }
/// <summary> /// The input strokes are all of the same stroke style, we put them tip to tail here, and discard dups. /// </summary> /// <param name="paths"></param> /// <returns></returns> private static DDW.Vex.Shape ConsolidatePaths(List <StrokePath> ps) { // don't destroy org path //List<StrokePath> ps = new List<StrokePath>(paths); DDW.Vex.Shape result = new DDW.Vex.Shape(); if (ps.Count == 0) { return(result); } result.Stroke = ps[0].StrokeStyle; List <IShapeData> rs = result.ShapeData; rs.Add(ps[0].Segment); Point curStart = ps[0].Segment.StartPoint; Point curEnd = ps[0].Segment.EndPoint; ps.RemoveAt(0); bool hasMatch = true; while (hasMatch && ps.Count > 0) { hasMatch = false; for (int i = 0; i < ps.Count; i++) { if (ps[i].Segment.StartPoint.Equals(curEnd) || ps[i].Segment.EndPoint.Equals(curEnd)) { StrokePath fp = ps[i]; ps.RemoveAt(i); // in this case, the segment is backwards (this can happen in swf) if (fp.Segment.EndPoint.Equals(curEnd)) { fp.Segment.Reverse(); } rs.Add(fp.Segment); curEnd = fp.Segment.EndPoint; hasMatch = true; if (curEnd == curStart) { hasMatch = false; } break; } } if (hasMatch == false && ps.Count > 0) { curStart = ps[0].Segment.StartPoint; curEnd = ps[0].Segment.EndPoint; rs.Add(ps[0].Segment); ps.RemoveAt(0); hasMatch = true; } } return(result); }
private void DrawSymbol(Vex.Symbol symbol) { for (int i = 0; i < symbol.Shapes.Count; i++) { Vex.Shape sh = symbol.Shapes[i]; DrawShape(sh); } }
//public PolygonShape2D(string containerName, List<Point> points) //{ // this.ContainerName = containerName; // this.Points = points; //} public PolygonShape2D(string containerName, Shape sh, Matrix m) { this.ContainerName = containerName; List<IShapeData> sd = sh.ShapeData; EnsureClockwise(sd); System.Drawing.PointF[] pts = new System.Drawing.PointF[ sd.Count]; for (int i = 0; i < sd.Count; i++) { pts[i] = new System.Drawing.PointF(sd[i].StartPoint.X, sd[i].StartPoint.Y); } System.Drawing.Drawing2D.Matrix m2 = m.GetDrawing2DMatrix(); m2.TransformPoints(pts); for (int i = 0; i < pts.Length; i++) { Points.Add(new Point(pts[i].X, pts[i].Y)); } }
private void DrawShape(Shape sh) { List<GraphicsPath> paths; if (sh.Fill != null) { paths = GetPath(sh.ShapeData, true); FillPaths(sh.Fill, paths); } if (sh.Stroke != null) { paths = GetPath(sh.ShapeData, false); StrokePaths(sh.Stroke, paths); } else { // this gets rid of slight aliasing spaces between touching vectors // todo: do average colors for gradients or something. if (sh.Fill.FillType == FillType.Solid) { StrokeStyle ss = new SolidStroke(.1F, ((SolidFill)sh.Fill).Color); paths = GetPath(sh.ShapeData, false); StrokePaths(ss, paths); } } }
/// <summary> /// The input strokes are all of the same stroke style, we put them tip to tail here, and discard dups. /// </summary> /// <param name="paths"></param> /// <returns></returns> private static DDW.Vex.Shape ConsolidatePaths(List<FillPath> ps) { // don't destroy org path //List<FillPath> ps = new List<FillPath>(paths); DDW.Vex.Shape result = new DDW.Vex.Shape(); if (ps.Count == 0) { return result; } result.Fill = ps[0].FillStyle; List<IShapeData> rs = result.ShapeData; rs.Add(ps[0].Segment); Point curStart = ps[0].Segment.StartPoint; Point curEnd = ps[0].Segment.EndPoint; ps.RemoveAt(0); bool hasMatch = true; while (hasMatch && ps.Count > 0) { hasMatch = false; for (int i = 0; i < ps.Count; i++) { if (ps[i].Segment.StartPoint == curEnd || ps[i].Segment.EndPoint == curEnd) { FillPath fp = ps[i]; ps.RemoveAt(i); // in this case, the segment is backwards (this can happen in swf) if (fp.Segment.EndPoint == curEnd) { fp.Segment.Reverse(); } rs.Add(fp.Segment); curEnd = fp.Segment.EndPoint; hasMatch = true; if (curEnd == curStart) { if (ps.Count > 0) { curStart = ps[0].Segment.StartPoint; curEnd = ps[0].Segment.EndPoint; rs.Add(ps[0].Segment); ps.RemoveAt(0); } else { hasMatch = false; } } break; } } } result.CalcuateBounds(); return result; }