public void DoDrawing(Pen pen, PenPosition penPosition, Graphics g, string line) { var Points = new ShapePoints { A = new Points { X = penPosition.X = 10, Y = penPosition.Y = 10 }, B = new Points { X = penPosition.X = 90, Y = penPosition.Y = 10 }, C = new Points { X = penPosition.X = 40, Y = penPosition.Y = 90 }, D = new Points { X = penPosition.X = 10, Y = penPosition.Y = 90 }, E = new Points { X = penPosition.X = 10, Y = penPosition.Y = 10 } }; Point[] points = { new Point(Points.A.X, Points.A.Y), new Point(Points.B.X, Points.B.Y), new Point(Points.C.X, Points.C.Y), new Point(Points.D.X, Points.D.Y), new Point(Points.E.X, Points.E.Y) }; g.DrawPolygon(pen, points); }
public void DoDrawing(Pen pen, PenPosition penPosition, Graphics g, string line) { var split = line.Split(); string Operator; var repeatSize = 5; Operator = split[2]; int.TryParse(split[3], out int AmountOfRepition); var Points = new ShapePoints { A = new Points { X = penPosition.X = 10, Y = penPosition.Y = 10 }, B = new Points { X = penPosition.X = 90, Y = penPosition.Y = 10 }, C = new Points { X = penPosition.X = 40, Y = penPosition.Y = 90 }, D = new Points { X = penPosition.X = 10, Y = penPosition.Y = 90 }, E = new Points { X = penPosition.X = 10, Y = penPosition.Y = 10 } }; if (Operator == "+") { for (int i = 0; i < AmountOfRepition; i++) { Point[] points = { new Point(Points.A.X += repeatSize, Points.A.Y += repeatSize), new Point(Points.B.X += repeatSize, Points.B.Y += repeatSize), new Point(Points.C.X += repeatSize, Points.C.Y += repeatSize), new Point(Points.D.X += repeatSize, Points.D.Y += repeatSize), new Point(Points.E.X += repeatSize, Points.E.Y += repeatSize) }; g.DrawPolygon(pen, points); } } if (Operator == "-") { for (int i = 0; i < AmountOfRepition; i++) { Point[] points = { new Point(Points.A.X -= repeatSize, Points.A.Y -= repeatSize), new Point(Points.B.X -= repeatSize, Points.B.Y -= repeatSize), new Point(Points.C.X -= repeatSize, Points.C.Y -= repeatSize), new Point(Points.D.X -= repeatSize, Points.D.Y -= repeatSize), new Point(Points.E.X -= repeatSize, Points.E.Y -= repeatSize) }; g.DrawPolygon(pen, points); } } }
//Initial shape points to be processed for X delta so that cloud moves to left. public Point[] ProcessedShapePoints() { var newPoints = new Point[ShapePoints.Count()]; for (int i = 0; i < ShapePoints.Count(); i++) { newPoints[i].X = ShapePoints[i].X - DeltaX; newPoints[i].Y = ShapePoints[i].Y; } return(newPoints); }
Mesh generateFaceMesh(ShapePoints shape) { var mesh = new Mesh(); var verts = new List <Vector3>(); var tris = new List <int>(); var uvs = new List <Vector2>(); var uv2 = new List <Vector2>(); var geometry = new InputGeometry(); for (int i = 0; i < shape.edge.Length; ++i) { var pt = shape.edge[i]; geometry.AddPoint(pt.x, pt.y); verts.Add(pt.p.AsVector3(-pt.groundness * _groundPull)); uvs.Add(pt.p); uv2.Add(new Vector2(pt.groundness * pt.groundness, 0)); geometry.AddSegment(i, (i + 1) % shape.edge.Length); } for (int i = 0; i < shape.interior.Length; ++i) { var pt = shape.interior[i]; geometry.AddPoint(pt.x, pt.y); verts.Add(pt.p.AsVector3(-pt.groundness * _groundPull + UnityEngine.Random.value * 0.4f)); uvs.Add(pt.p); uv2.Add(new Vector2(pt.groundness * pt.groundness, 0)); } var behave = new TriangleNet.Behavior(); behave.Algorithm = TriangleNet.TriangulationAlgorithm.Incremental; var meshRepresentation = new TriangleNet.Mesh(behave); meshRepresentation.Triangulate(geometry); foreach (var tri in meshRepresentation.Triangles) { tris.Add(tri.GetVertex(2).ID); tris.Add(tri.GetVertex(1).ID); tris.Add(tri.GetVertex(0).ID); } mesh.vertices = verts.ToArray(); mesh.triangles = tris.ToArray(); mesh.uv = uvs.ToArray(); mesh.uv2 = uv2.ToArray(); mesh.RecalculateNormals(); mesh.RecalculateBounds(); return(mesh); }
public void ResetPoints() { t.ShapeArray = ShapePoints; t.BuildBoundingBox(); SPoint sub = new SPoint(0, t.bounds.Top); for (int i = 0; i < ShapePoints.Count(); i++) { ShapePoints[i] -= sub; } //ShapePoints.ForEach(delegate(SPoint s) { s -= new SPoint(100,100); }); }
/// <summary> /// Attempts to convert a ShapeItem to PathGeometry /// </summary> /// <param name="value"></param> /// <param name="targetType"></param> /// <param name="parameter"></param> /// <param name="culture"></param> /// <returns></returns> public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { ShapePoints item = value as ShapePoints; if (item != null && item.Count > 0) { Point start = item[0]; List <LineSegment> segments = new List <LineSegment>(); for (int i = 1; i < item.Count; i++) { segments.Add(new LineSegment(item[i], true)); } PathFigure figure = new PathFigure(start, segments, item.IsPolygon); PathGeometry geometry = new PathGeometry(); geometry.Figures.Add(figure); return(geometry); } else { return(null); } }
/// <summary> /// Creates a ShapeItem /// </summary> /// <param name="layer">The layer the item resides on</param> /// <param name="name">The name of the item</param> /// <param name="points">A list of points the item consists of</param> /// <param name="position">The position of the item</param> /// <param name="zIndex">The index depth of the item</param> /// <param name="isPolygon">Flags whether the item is a polygon or not (defauls to true)</param> public ShapeItem(string layer, string name, List <Point> points, WorldPosition position, int zIndex, bool isPolygon = true) { // Set class type this.type = typeof(ShapeItem).Name; this.layer = layer; this.name = name; this.position = position; this.zIndex = zIndex; this.size = new Point(); this.isSelected = false; this.isVisible = true; this.fill = new SolidColorBrush(Colors.Red); this.fillOpacity = 0.5f; this.fill.Opacity = fillOpacity; this.stroke = new SolidColorBrush(Colors.Red); this.strokeThickness = 1; this.properties = new ObservableCollection <ItemProperty>(); this.points = new ShapePoints(isPolygon, points); }