private void AddPoint(Single x, Single y, PathPointType pointType) { _points.Add(new ValuePoint2F(x, y)); _pointTypes.Add(pointType); }
private static void DrawPath(this WavefrontFormat wf, GraphicsPath path) { byte[] types = path.PathData.Types; PointF[] points = path.PathData.Points; FillMode fillMode = path.FillMode; List <Point2d> _points = new List <Point2d>(); for (int i = 0; i < types.Length; i++) { PathPointType tipo = (PathPointType)types[i] & PathPointType.PathTypeMask; switch (tipo) { case PathPointType.Start: { _points.Add(new Point2d(points[i].X, points[i].Y)); break; } case PathPointType.Line: { _points.Add(new Point2d(points[i].X, points[i].Y)); break; } case PathPointType.Bezier3: { // NOTA: se pintará una bezier en breve. _points.Add(new Point2d(points[i].X, points[i].Y)); i++; _points.Add(new Point2d(points[i].X, points[i].Y)); i++; _points.Add(new Point2d(points[i].X, points[i].Y)); break; } default: { throw new IndexOutOfRangeException(); } } // El ultimo tipo determina si hay que cerrar. bool cerrar = ((PathPointType)types[i] & PathPointType.CloseSubpath) == PathPointType.CloseSubpath; if (cerrar) { if (_points.Count > 0) { wf.AddLines(_points, true); _points.Clear(); } } } if (_points.Count > 0) { wf.AddLines(_points, false); _points.Clear(); } }
public static GeometryPathType ReadXml(XmlReader reader) { GeometryPathType gpt = new GeometryPathType(); if (reader.HasAttributes) { gpt.PathOpen = Convert.ToBoolean(reader.GetAttribute("PathOpen")); } if (reader.IsEmptyElement) { return(gpt); } while (reader.Read()) { if (reader.Name == "PathPointType") { gpt.PathPoints.Add(PathPointType.ReadXml(reader)); } else if (reader.Name == "GeometryPathType" & reader.NodeType == XmlNodeType.EndElement) { break; } } return(gpt); }
private Boolean TryAddConnectingPoint(Single x, Single y, PathPointType pointType) { if (_points.Count > 0) { var lastPoint = _points[_points.Count - 1]; if (lastPoint.X.AreEqualEnough(x) && lastPoint.Y.AreEqualEnough(y)) { return(false); } } if (_points.Count == 0 || _isPendingStart) { _pointTypes.Add(PathPointType.Start); } else { _pointTypes.Add(pointType); } _points.Add(new ValuePoint2F(x, y)); if (_isPendingStart) { _isPendingStart = false; } return(true); }
public PathPoint(PathPointType pathPointType, Node node, Edge edge, Vector3 position) { this.pathPointType = pathPointType; this.node = node; this.edge = edge; this.position = position; }
/// <summary> /// Tesselates the specified path, notifying the /// <see cref="UMD.HCIL.PiccoloDirect3D.Util.TesselationVisitor">TesselationVisitor</see> /// as each new triangle primitive is added. /// </summary> /// <param name="path">The path to tesselate.</param> /// <param name="visitor">The tesselation visitor to notify.</param> public virtual void Tesselate(GraphicsPath path, TesselationVisitor visitor) { this.visitor = visitor; switch (path.FillMode) { case FillMode.Alternate: //even/odd P3Util.SetWindingRule(tess, P3Util.GlTessWinding.WindingOdd); break; case FillMode.Winding: //nonzero P3Util.SetWindingRule(tess, P3Util.GlTessWinding.WindingNonzero); break; } P3Util.GluTessBeginPolygon(tess, IntPtr.Zero); bool isClosed; GraphicsPathIterator pi = new GraphicsPathIterator(path); PointF[] points = path.PathPoints; while (pi.NextSubpath(path, out isClosed) != 0) { byte type; int start, end; while (pi.NextPathType(out type, out start, out end) != 0) { PathPointType ppType = (PathPointType)type; P3Util.GluTessBeginContour(tess); for (int i = start; i <= end; i++) { PointF point = points[i]; double[] coords = new double[3]; coords[0] = point.X; coords[1] = point.Y; coords[2] = 0; GCHandle handle = GCHandle.Alloc(coords, GCHandleType.Pinned); P3Util.GluTessVertex(tess, coords, (IntPtr)handle); handles.Add(handle); } P3Util.GluTessEndContour(tess); } } P3Util.GluTessEndPolygon(tess); ClearHandles(); }
public static PathPointType ReadXml(XmlReader reader) { PathPointType ppt = new PathPointType(); if (reader.HasAttributes) { ppt.Anchor = new UnitPointType(reader.GetAttribute("Anchor")); ppt.LeftDirection = new UnitPointType(reader.GetAttribute("LeftDirection")); ppt.RightDirection = new UnitPointType(reader.GetAttribute("RightDirection")); } return(ppt); }
public GraphicsPath GetShape(int pointCount, PathPointType pointType) { List <Point> pnts = new List <Point>(pointCount); List <byte> pntTypes = new List <byte>(pointCount); for (int i = 0; i < pointCount; i++) { double a = (double)(i + 1) / ((double)pointCount / 2) * System.Math.PI; int x = (int)System.Math.Truncate(this.Center.X + this.Radius * System.Math.Sin(a)); int y = (int)System.Math.Truncate(this.Center.Y + this.Radius * System.Math.Cos(a)); pnts.Add(new Point(x, y)); pntTypes.Add((byte)pointType); } pnts.Add(new Point(pnts[0].X, pnts[0].Y)); pntTypes.Add((byte)pointType); return(new GraphicsPath(pnts.ToArray(), pntTypes.ToArray())); }
public GraphicsPath GetShape(int pointCount, PathPointType pointType) { List <PointF> pnts = new List <PointF>(pointCount); List <byte> pntTypes = new List <byte>(pointCount); for (int i = 0; i < pointCount; i++) { double a = (double)(i + 1) / ((double)pointCount / 2) * System.Math.PI; double x = this.Center.X + this.Radius * System.Math.Sin(a); double y = this.Center.Y + this.Radius * System.Math.Cos(a); pnts.Add(new PointF((float)x, (float)y)); pntTypes.Add((byte)pointType); } pnts.Add(new PointF(pnts[0].X, pnts[0].Y)); pntTypes.Add((byte)pointType); return(new GraphicsPath(pnts.ToArray(), pntTypes.ToArray())); }
void Append(float x, float y, PathPointType type, bool compress) { byte t = (byte)type; PointF pt = PointF.Empty; /* in some case we're allowed to compress identical points */ if (compress && (points.Count > 0)) { /* points (X, Y) must be identical */ PointF lastPoint = points [points.Count - 1]; if ((lastPoint.X == x) && (lastPoint.Y == y)) { /* types need not be identical but must handle closed subpaths */ PathPointType last_type = (PathPointType)types [types.Count - 1]; if ((last_type & PathPointType.CloseSubpath) != PathPointType.CloseSubpath) { return; } } } if (start_new_fig) { t = (byte)PathPointType.Start; } /* if we closed a subpath, then start new figure and append */ else if (points.Count > 0) { type = (PathPointType)types [types.Count - 1]; if ((type & PathPointType.CloseSubpath) != 0) { t = (byte)PathPointType.Start; } } pt.X = x; pt.Y = y; points.Add(pt); types.Add(t); start_new_fig = false; }
void AppendCurve(PointF [] points, PointF [] tangents, int offset, int length, CurveType type) { PathPointType ptype = ((type == CurveType.Close) || (points.Length == 0)) ? PathPointType.Start : PathPointType.Line; int i; AppendPoint(points [offset], ptype, true); for (i = offset; i < offset + length; i++) { int j = i + 1; float x1 = points [i].X + tangents [i].X; float y1 = points [i].Y + tangents [i].Y; float x2 = points [j].X - tangents [j].X; float y2 = points [j].Y - tangents [j].Y; float x3 = points [j].X; float y3 = points [j].Y; AppendBezier(x1, y1, x2, y2, x3, y3); } /* complete (close) the curve using the first point */ if (type == CurveType.Close) { float x1 = points [i].X + tangents [i].X; float y1 = points [i].Y + tangents [i].Y; float x2 = points [0].X - tangents [0].X; float y2 = points [0].Y - tangents [0].Y; float x3 = points [0].X; float y3 = points [0].Y; AppendBezier(x1, y1, x2, y2, x3, y3); CloseFigure(); } }
void AppendPoint(PointF point, PathPointType type, bool compress) { Append (point.X, point.Y, type, compress); }
void Append(float x, float y, PathPointType type, bool compress) { byte t = (byte) type; PointF pt = PointF.Empty; /* in some case we're allowed to compress identical points */ if (compress && (points.Count > 0)) { /* points (X, Y) must be identical */ PointF lastPoint = points [points.Count-1]; if ((lastPoint.X == x) && (lastPoint.Y == y)) { /* types need not be identical but must handle closed subpaths */ PathPointType last_type = (PathPointType) types [types.Count-1]; if ((last_type & PathPointType.CloseSubpath) != PathPointType.CloseSubpath) return; } } if (start_new_fig) t = (byte) PathPointType.Start; /* if we closed a subpath, then start new figure and append */ else if (points.Count > 0) { type = (PathPointType) types [types.Count-1]; if ((type & PathPointType.CloseSubpath) != 0) t = (byte)PathPointType.Start; } pt.X = x; pt.Y = y; points.Add (pt); types.Add (t); start_new_fig = false; }
public GraphicsPath GetShape(int pointCount, PathPointType pointType) { List<Point> pnts = new List<Point>(pointCount); List<byte> pntTypes = new List<byte>(pointCount); for (int i = 0; i < pointCount; i++) { double a = (double)(i + 1) / ((double)pointCount / 2) * System.Math.PI; int x = (int)System.Math.Truncate(this.Center.X + this.Radius * System.Math.Sin(a)); int y = (int)System.Math.Truncate(this.Center.Y + this.Radius * System.Math.Cos(a)); pnts.Add(new Point(x, y)); pntTypes.Add((byte)pointType); } pnts.Add(new Point(pnts[0].X, pnts[0].Y)); pntTypes.Add((byte)pointType); return new GraphicsPath(pnts.ToArray(), pntTypes.ToArray()); }
public GraphicsPath GetShape(int pointCount, PathPointType pointType) { List<PointF> pnts = new List<PointF>(pointCount); List<byte> pntTypes = new List<byte>(pointCount); for (int i = 0; i < pointCount; i++) { double a = (double)(i + 1) / ((double)pointCount / 2) * System.Math.PI; double x = this.Center.X + this.Radius * System.Math.Sin(a); double y = this.Center.Y + this.Radius * System.Math.Cos(a); pnts.Add(new PointF((float)x, (float)y)); pntTypes.Add((byte)pointType); } pnts.Add(new PointF(pnts[0].X, pnts[0].Y)); pntTypes.Add((byte)pointType); return new GraphicsPath(pnts.ToArray(), pntTypes.ToArray()); }
void AddPoint(PointFx point, PathPointType type) { pts.Add(point); types.Add(type); }
void AppendPoint(PointF point, PathPointType type, bool compress) { Append(point.X, point.Y, type, compress); }
public string ToString (PathPointType type) { foreach (PathPointType t in Enum.GetValues(typeof (PathPointType))) if (type == t) return type.ToString (); string s = (type & PathPointType.PathTypeMask).ToString (); foreach (PathPointType t in new PathPointType[] {PathPointType.PathMarker, PathPointType.CloseSubpath}) if ((type & t) != 0) s += " | " + t.ToString (); return s; }
private void AddPoint(IPoint2F p, PathPointType pointType) { _points.Add(p); _pointTypes.Add(pointType); }