public void DrawRoad(Road road, Color linecolor, Color startColor, Color endColor, bool drawStartEnd = true, int width = 1) { //width = line.Intersected ? width + 1 : width; DrawLine(road, linecolor, width); if (drawStartEnd) { DrawPoint(road.Start, 7, Colors.Red); DrawPoint(road.End, 7, Colors.Red); } var slope = road.Slope(); var pc = Color.FromRgb(50, 50, 50); foreach (var building in road.Buildings) { DrawPoint(building, 4, pc); //Draw bounds of the building //DrawRectangle(building,building.Width,building.Height,pc); var halfWidth = (building.Width / 2); var halfLength = (building.Height / 2); var boundX = new Point(building.X - halfWidth, building.Y - halfLength); var boundY = new Point(building.X + halfWidth, building.Y + halfLength); //DrawLine(boundY,boundX, pc, 1); } }
float Distance(Point a, Point b) { float dx = a.x - b.x; float dy = a.y - b.y; return(Mathf.Sqrt(dx * dx + dy * dy)); }
public void DrawRectangle(Rectangle rect, Color c) { var p1 = new Point(rect.Left, rect.Top); var p2 = new Point(rect.Left, rect.Bottom); var p3 = new Point(rect.Right, rect.Bottom); var p4 = new Point(rect.Right, rect.Top); DrawLine(p1, p2, c); DrawLine(p2, p3, c); DrawLine(p3, p4, c); DrawLine(p4, p1, c); }
public void DrawText(string text, Color c, Point position) { var textBlock = new TextBlock { Text = text, Foreground = new SolidColorBrush(c) }; Canvas.SetLeft(textBlock, position.X); Canvas.SetTop(textBlock, position.Y); _drawCanvas.Children.Add(textBlock); }
/// <summary> /// Draw a line from point 1 to point 2 /// </summary> public void DrawLine(Point p1, Point p2, Color c, int thick = 1) { var thickness = new Thickness(0, 0, 0, 0); var line = new Line { Margin = thickness, Visibility = Visibility.Visible, StrokeThickness = thick, Stroke = new SolidColorBrush(c), X1 = p1.X, Y1 = p1.Y, X2 = p2.X, Y2 = p2.Y }; _drawCanvas.Children.Add(line); }
/// <summary> /// Add a point to the canvas /// </summary> public void DrawPoint(Point p, double radius, Color c) { //Create the point var point = new Ellipse { Fill = new SolidColorBrush(c), Width = radius, Height = radius, }; //position it on the canvas Canvas.SetLeft(point, p.X - (radius / 2)); Canvas.SetTop(point, p.Y - (radius / 2)); //draw it _drawCanvas.Children.Add(point); }
private Line CreateIntersectedLine(Line newLine,Point ip, ref bool flipped) { var start = newLine.Start; var end = newLine.End; //Check if the new line will not be too small //if it is too small switch the start point with the previous end point var totalDistance = MathHelpers.DistanceBetweenPoints(start, end); var newDistance = MathHelpers.DistanceBetweenPoints(start, ip); //Create the new line //swap occurs when the new distance is smaller than 1/3 of the original distance flipped = newDistance < (totalDistance*0.33); var line = flipped? new Line(ip,end) : new Line(start, ip); return line; }
/// <summary> /// Draw Rectangle from a point and width and height /// </summary> public void DrawRectangle(Point p, int width, int height, Color c) { var halfWidth = width / 2; var halfHeigth = height / 2; //Create 3 other points var pWidth = new Point(p.X + halfWidth, p.Y - halfHeigth); var pHeight = new Point(p.X - halfWidth, p.Y + halfHeigth); var pWidthHeight = new Point(p.X + halfWidth, p.Y + halfHeigth); p = new Point(p.X - halfWidth, p.Y - halfHeigth); //Draw DrawLine(p, pWidth, c); DrawLine(p, pHeight, c); DrawLine(pHeight, pWidthHeight, c); DrawLine(pWidth, pWidthHeight, c); }
void CreateSites(bool clear = true, bool relax = false, int relaxCount = 2) { List <Point> sites = new List <Point>(); if (!clear) { sites = this.sites.Take(this.sites.Count).ToList(); } // create vertices for (int i = 0; i < numSites; i++) { Point site = new Point(Random.Range(bounds.min.x, bounds.max.x), Random.Range(bounds.min.z, bounds.max.z), 0); sites.Add(site); } Compute(sites); if (relax) { RelaxSites(relaxCount); } }
public void DrawTriangle(Point p1, Point p2, Point p3, Color c) { DrawLine(p1, p2, c,2); DrawLine(p3, p2, c,2); DrawLine(p1, p3, c,2); }
public Road(Point start,Point end) : base(start, end) { Buildings = new List<BuildingSite>(); }
public static BuildingSite FromPoint(Point p) { var b = new BuildingSite(p.X, p.Y); return b; }
/// <summary> /// Draw a line from point 1 to point 2 /// </summary> public void DrawLine(Point p1, Point p2, Color c,int thick = 1) { var thickness = new Thickness(0, 0, 0, 0); var line = new Line { Margin = thickness, Visibility = Visibility.Visible, StrokeThickness = thick, Stroke = new SolidColorBrush(c), X1 = p1.X, Y1 = p1.Y, X2 = p2.X, Y2 = p2.Y }; _drawCanvas.Children.Add(line); }
public void DrawTriangle(Point p1, Point p2, Point p3, Color c) { DrawLine(p1, p2, c, 2); DrawLine(p3, p2, c, 2); DrawLine(p1, p3, c, 2); }
private SplitLine SplitLine(Line line, Point ip) { var start = line.Start; var end = line.End; return new SplitLine(new Line(start,ip),new Line(ip,end)); }
public void DrawRoad(Road road, Color linecolor, Color startColor, Color endColor, bool drawStartEnd = true, int width = 1) { //width = line.Intersected ? width + 1 : width; DrawLine(road,linecolor, width); if (drawStartEnd) { DrawPoint(road.Start, 7, Colors.Red); DrawPoint(road.End, 7, Colors.Red); } var slope = road.Slope(); var pc = Color.FromRgb(50,50,50); foreach (var building in road.Buildings) { DrawPoint(building, 4, pc); //Draw bounds of the building //DrawRectangle(building,building.Width,building.Height,pc); var halfWidth = (building.Width/2); var halfLength = (building.Height/2); var boundX = new Point(building.X - halfWidth, building.Y - halfLength); var boundY = new Point(building.X + halfWidth, building.Y + halfLength); //DrawLine(boundY,boundX, pc, 1); } }
public void DrawRectangle(Rectangle rect, Color c) { var p1 = new Point(rect.Left, rect.Top); var p2 = new Point(rect.Left, rect.Bottom ); var p3 = new Point(rect.Right, rect.Bottom); var p4 = new Point(rect.Right , rect.Top); DrawLine(p1, p2, c); DrawLine(p2, p3, c); DrawLine(p3, p4, c); DrawLine(p4, p1, c); }
/// <summary> /// Draw Rectangle from a point and width and height /// </summary> public void DrawRectangle(Point p,int width, int height,Color c) { var halfWidth = width/2; var halfHeigth = height/2; //Create 3 other points var pWidth = new Point(p.X + halfWidth, p.Y - halfHeigth); var pHeight = new Point(p.X - halfWidth, p.Y + halfHeigth); var pWidthHeight = new Point(p.X + halfWidth, p.Y + halfHeigth); p = new Point(p.X - halfWidth, p.Y - halfHeigth); //Draw DrawLine(p,pWidth,c); DrawLine(p, pHeight, c); DrawLine(pHeight, pWidthHeight, c); DrawLine(pWidth, pWidthHeight, c); }