static void DrawTriangle(FoxDraw foxDraw, double startx, double starty, double endx, double endy, int count) { foxDraw.StrokeColor(Colors.Black); foxDraw.FillColor(Colors.White); foxDraw.BackgroundColor(Colors.Gray); var points = new List <Point>(); points.Add(new Point(startx, starty)); points.Add(new Point(endx, starty)); points.Add(new Point(startx + (endx - startx) / 2, endy)); foxDraw.DrawPolygon(points); var points2 = new List <Point>(); points2.Add(new Point(startx + (endx - startx) / 2, starty)); points2.Add(new Point(startx + (endx - startx) / 4, starty + (endy - starty) / 2)); points2.Add(new Point(startx + (endx - startx) * 3 / 4, starty + (endy - starty) / 2)); foxDraw.DrawPolygon(points2); count--; if (count > 0) { DrawTriangle(foxDraw, startx + (endx - startx) / 2, starty, endx, starty + (endy - starty) / 2, count); DrawTriangle(foxDraw, startx, starty, startx + (endx - startx) / 2, starty + (endy - starty) / 2, count); DrawTriangle(foxDraw, startx + (endx - startx) / 4, starty + (endy - starty) / 2, startx + (endx - startx) * 3 / 4, endy, count); } }
public void Triangle(double coor1, double coor2, double size, int n) { InitializeComponent(); var foxDraw = new FoxDraw(canvas); var left = new Point(coor1, coor2); var right = new Point(coor1 + size / 2, coor2); var top = new Point(coor1 + size / 4, coor2 + size / 2); Point[] points = { left, right, top }; foxDraw.StrokeColor(Colors.Black); foxDraw.FillColor(Colors.Transparent); foxDraw.DrawPolygon(points); var left2 = new Point(coor1 + size / 2, coor2); var bottom2 = new Point(coor1 + size, coor2); var top2 = new Point(coor1 + size - (size / 4), coor2 + size / 2); Point[] points2 = { left2, bottom2, top2 }; foxDraw.DrawPolygon(points2); var left3 = new Point(coor1 + size / 4, coor2 + size / 2); var bottom3 = new Point(coor1 + size - (size / 4), coor2 + size / 2); var top3 = new Point(coor1 + size / 2, coor2 + size); Point[] points3 = { left3, bottom3, top3 }; foxDraw.DrawPolygon(points3); if (n > 0) { Triangle(coor1, coor2, size / 2, n - 1); Triangle(coor1 + size / 2, coor2, size / 2, n - 1); Triangle(coor1 + size / 4, coor2 + size / 2, size / 2, n - 1); } }
public void drawBox(FoxDraw foxDraw, double boxSize, Point startingPoint) { var xAdjustment = (Math.Sqrt(3) / 2) * boxSize; Point a = new Point(startingPoint.X, startingPoint.Y); Point b = new Point(xAdjustment + startingPoint.X, 0.5 * boxSize + startingPoint.Y); Point c = new Point(xAdjustment + startingPoint.X, 1.5 * boxSize + startingPoint.Y); Point d = new Point(startingPoint.X, 2 * boxSize + startingPoint.Y); Point e = new Point(-xAdjustment + startingPoint.X, 1.5 * boxSize + startingPoint.Y); Point f = new Point(-xAdjustment + startingPoint.X, 0.5 * boxSize + startingPoint.Y); Point center = new Point(startingPoint.X, boxSize + startingPoint.Y); foxDraw.SetStrokeThicknes(0); // #4EB99F foxDraw.SetFillColor(Colors.Beige); foxDraw.DrawPolygon(new List <Point> { a, b, center, f }); // #078388 foxDraw.SetFillColor(Colors.Black); foxDraw.DrawPolygon(new List <Point> { b, c, d, center }); // #122F41 foxDraw.SetFillColor(Colors.DimGray); foxDraw.DrawPolygon(new List <Point> { center, d, e, f }); }
static void SquarePorn(FoxDraw foxDraw, Point start, Point end, int count) { foxDraw.StrokeColor(Colors.Black); foxDraw.FillColor(Colors.Transparent); List <Point> list = new List <Point>(); list.Add(new Point(start.X + (end.X - start.X) / 4, start.Y + (end.Y - start.Y) / 4)); list.Add(new Point(start.X + (end.X - start.X) * 3 / 4, start.Y + (end.Y - start.Y) / 4)); list.Add(new Point(start.X + (end.X - start.X) * 3 / 4, start.Y + (end.Y - start.Y) * 3 / 4)); list.Add(new Point(start.X + (end.X - start.X) / 4, start.Y + (end.Y - start.Y) * 3 / 4)); foxDraw.DrawPolygon(list); count--; if (count > 0) { Point point1 = new Point(start.X + (end.X - start.X) / 2, start.Y); Point point2 = new Point(start.X, start.Y + (end.Y - start.Y) / 2); Point point3 = new Point(start.X + (end.X - start.X) / 2, start.Y + (end.Y - start.Y) / 2); Point point4 = new Point(end.X, start.Y + (end.Y - start.Y) / 2); Point point5 = new Point(start.X + (end.X - start.X) / 2, end.Y); SquarePorn(foxDraw, start, point3, count); SquarePorn(foxDraw, point1, point4, count); SquarePorn(foxDraw, point2, point5, count); SquarePorn(foxDraw, point3, end, count); } }
static void HexaDrawer(FoxDraw foxDraw, Point start, Point end, int count) { foxDraw.StrokeColor(Colors.Black); foxDraw.FillColor(Colors.White); foxDraw.BackgroundColor(Colors.Gray); var points = new List <Point>(); points.Add(new Point(start.X + (end.X - start.X) / 4, start.Y)); points.Add(new Point(start.X + (end.X - start.X) * 3 / 4, start.Y)); points.Add(new Point(end.X, start.Y + (end.Y - start.Y) / 2)); points.Add(new Point(start.X + (end.X - start.X) * 3 / 4, end.Y)); points.Add(new Point(start.X + (end.X - start.X) / 4, end.Y)); points.Add(new Point(start.X, start.Y + (end.Y - start.Y) / 2)); foxDraw.DrawPolygon(points); count--; if (count > 0) { HexaDrawer(foxDraw, new Point(start.X + (end.X - start.X) / 6, start.Y), new Point(start.X + (end.X - start.X) / 2, start.Y + (end.Y - start.Y) / 3), count); HexaDrawer(foxDraw, new Point(start.X + (end.X - start.X) / 2, start.Y), new Point(start.X + (end.X - start.X) * 5 / 6, start.Y + (end.Y - start.Y) / 3), count); HexaDrawer(foxDraw, new Point(start.X, start.Y + (end.Y - start.Y) / 3), new Point(start.X + (end.X - start.X) / 3, start.Y + (end.Y - start.Y) * 2 / 3), count); HexaDrawer(foxDraw, new Point(start.X + (end.X - start.X) * 2 / 3, start.Y + (end.Y - start.Y) / 3), new Point(end.X, start.Y + (end.Y - start.Y) * 2 / 3), count); HexaDrawer(foxDraw, new Point(start.X + (end.X - start.X) / 6, start.Y + (end.Y - start.Y) * 2 / 3), new Point(start.X + (end.X - start.X) / 2, end.Y), count); HexaDrawer(foxDraw, new Point(start.X + (end.X - start.X) / 2, start.Y + (end.Y - start.Y) * 2 / 3), new Point(start.X + (end.X - start.X) * 5 / 6, end.Y), count); } }
public MainWindow() { InitializeComponent(); var foxDraw = new FoxDraw(canvas); // draw four different size and color rectangles. // avoid code duplication. foxDraw.FillColor(Colors.Blue); foxDraw.DrawRectangle(250, 250, 50, 80); var points = new List <Point>(); points.Add(new Point(650, 10)); points.Add(new Point(750, 10)); points.Add(new Point(750, 100)); points.Add(new Point(650, 100)); foxDraw.FillColor(Colors.Green); foxDraw.DrawPolygon(points); foxDraw.StrokeColor(Colors.Red); foxDraw.DrawLine(50, 50, 160, 50); foxDraw.DrawLine(160, 50, 160, 75); foxDraw.DrawLine(160, 75, 50, 75); foxDraw.DrawLine(50, 75, 50, 50); //foxDraw.AddImage(, 450, 450); }
public static void DrawTriangle(FoxDraw foxDraw) { int x = 25; double setStartPointX = 0; double setStartPointY = 600; for (int k = 12; k >= 0; k--) { double startPointX = setStartPointX; double startPointY = setStartPointY; for (int i = 0; i < k; i++) { var points = new List <Point>(); points.Add(new Point(startPointX, startPointY)); points.Add(new Point(startPointX + 2 * x, startPointY)); points.Add(new Point(startPointX + x, startPointY - x * System.Math.Sqrt(3))); foxDraw.FillColor(Colors.White); foxDraw.DrawPolygon(points); startPointX = startPointX + x; startPointY = startPointY - x * System.Math.Sqrt(3); } setStartPointX = setStartPointX + 2 * x; } }
public static void DrawGreenPolygon(FoxDraw foxDraw) { var points = new List <Point>(); points.Add(new Point(10, 10)); points.Add(new Point(40, 210)); points.Add(new Point(170, 190)); points.Add(new Point(130, 40)); foxDraw.SetFillColor(Colors.Green); foxDraw.DrawPolygon(points); }
public static void DrawPolygon(FoxDraw foxDraw, int s, int a) { var points = new List <Point>(); points.Add(new Point(s, a)); points.Add(new Point(s, 2 * a)); points.Add(new Point(2 * a, 2 * s)); points.Add(new Point(2 * s, a)); foxDraw.FillColor(Colors.Purple); foxDraw.DrawPolygon(points); }
private void DrawSquare(FoxDraw foxDraw, Point middlepoint, int squaresize) { var squarepoints = new List <Point>() { new Point(middlepoint.X - squaresize, middlepoint.Y - squaresize), new Point(middlepoint.X + squaresize, middlepoint.Y - squaresize), new Point(middlepoint.X + squaresize, middlepoint.Y + squaresize), new Point(middlepoint.X - squaresize, middlepoint.Y + squaresize), }; foxDraw.DrawPolygon(squarepoints); }
private void DrawSquare(FoxDraw foxDraw, Point startpoint) { var pointlist = new List <Point>() { new Point(startpoint.X, startpoint.Y), new Point(startpoint.X + 50, startpoint.Y), new Point(startpoint.X + 50, startpoint.Y + 50), new Point(startpoint.X, startpoint.Y + 50) }; foxDraw.DrawPolygon(pointlist); }
public static void DrawPolygon(FoxDraw foxDraw, int s, int a) { var points = new List <Point>(); points.Add(new Point(s, a)); points.Add(new Point(s, a + 30)); points.Add(new Point(s + 30, a + 30)); points.Add(new Point(s + 30, a)); foxDraw.DrawPolygon(points); }
public static void DrawGreenPolygon4(FoxDraw foxDraw, Canvas canvas) { var points = new List <Point>(); points.Add(new Point(canvas.Width * 2 / 3, canvas.Height / 3)); points.Add(new Point(canvas.Width * 2 / 3, canvas.Height * 2 / 3)); points.Add(new Point(canvas.Width, canvas.Height * 2 / 3)); points.Add(new Point(canvas.Width, canvas.Height / 3)); foxDraw.FillColor(Colors.Red); foxDraw.DrawPolygon(points); }
public static void DrawPolygon(FoxDraw foxDraw, int s, int a) { var points = new List <Point>(); points.Add(new Point(s, a)); points.Add(new Point(s + 50, a)); points.Add(new Point(a + 50, s + 50)); points.Add(new Point(s, a + 50)); foxDraw.FillColor(Colors.Magenta); foxDraw.DrawPolygon(points); }
public static void DrawPolygon(FoxDraw foxDraw, double p, byte w) { var s = p / 2; var b = p; var points = new List <Point>(); points.Add(new Point(s, s + 30)); points.Add(new Point(s, b)); points.Add(new Point(b, b)); points.Add(new Point(b, s + 30)); foxDraw.DrawPolygon(points); foxDraw.FillColor(Color.FromRgb(w, 50, 50)); }
public void DrawSquare(FoxDraw foxDraw, Point middlepoint, int size) { var squarepoints = new List <Point>() { new Point(middlepoint.X - size, middlepoint.Y - size), new Point(middlepoint.X + size, middlepoint.Y - size), new Point(middlepoint.X + size, middlepoint.Y + size), new Point(middlepoint.X - size, middlepoint.Y + size), }; //foxDraw.FillColor(Color.FromArgb(255, Convert.ToByte(rnd.Next(0, 256)), Convert.ToByte(rnd.Next(0, 256)), Convert.ToByte(rnd.Next(0, 256)))); foxDraw.DrawPolygon(squarepoints); }
private void DrawSquares(FoxDraw foxDraw, int size, Point start) { var pointlist = new List <Point>() { new Point(start.X, start.Y), new Point(start.X + size, start.Y), new Point(start.X + size, start.Y + size), new Point(start.X, start.Y + size), }; foxDraw.FillColor(Colors.Purple); foxDraw.DrawPolygon(pointlist); }
private void DrawFrame(FoxDraw foxDraw) { var points = new List <Point> { new Point(0, 0), new Point(400, 0), new Point(400, 400), new Point(0, 400) }; foxDraw.StrokeColor(Colors.Black); foxDraw.FillColor(Colors.White); foxDraw.DrawPolygon(points); }
public static void DrawGreenPolygon(FoxDraw foxDraw, int squareSide) { var half = 150; //canvas.ActualHeight / 2; var x = half - squareSide / 2; var y = half + squareSide / 2; var points = new List <Point>(); points.Add(new Point(x, x)); points.Add(new Point(x, y)); points.Add(new Point(y, y)); points.Add(new Point(y, x)); foxDraw.FillColor(Colors.Green); foxDraw.DrawPolygon(points); }
public static void DrawHexagon(FoxDraw foxDraw, double startingPointX, double startingPointY, double side) { double height = side * Math.Sqrt(3); var points = new List <Point>(); points.Add(new Point(startingPointX, startingPointY)); points.Add(new Point(startingPointX += side, startingPointY)); points.Add(new Point(startingPointX += side / 2, startingPointY += height / 2)); points.Add(new Point(startingPointX -= side / 2, startingPointY += height / 2)); points.Add(new Point(startingPointX -= side, startingPointY)); points.Add(new Point(startingPointX -= side / 2, startingPointY -= height / 2)); foxDraw.StrokeColor(Colors.Black); foxDraw.DrawPolygon(points); }
private void drawBox(FoxDraw foxDraw, double boxSize, Point startingPoint) { var xAdjustment = Math.Sqrt(3) / 2 * boxSize; Point a = new Point(+startingPoint.X, +startingPoint.Y); Point b = new Point(xAdjustment + startingPoint.X, 0.5 * boxSize + startingPoint.Y); Point c = new Point(xAdjustment + startingPoint.X, 1.5 * boxSize + startingPoint.Y); Point d = new Point(+startingPoint.X, 2 * boxSize + startingPoint.Y); Point e = new Point(-xAdjustment + startingPoint.X, 1.5 * boxSize + startingPoint.Y); Point f = new Point(-xAdjustment + startingPoint.X, 0.5 * boxSize + startingPoint.Y); Point center = new Point(0, boxSize); List <Point> vertices = new List <Point> { a, b, c, d, e, f, center }; for (int i = 0; i < vertices.Count; i++) { vertices[i] = new Point(vertices[i].X + startingPoint.X, vertices[i].Y + startingPoint.Y); } foxDraw.SetFillColor(Color.Parse("FFA400")); foxDraw.DrawPolygon(new List <Point> { a, b, center, f, a }); foxDraw.SetFillColor(Color.Parse("#078388")); foxDraw.DrawPolygon(new List <Point> { b, c, d, center, b }); foxDraw.SetFillColor(Color.Parse("#078397")); foxDraw.DrawPolygon(new List <Point> { center, d, e, a, center }); }
public MainWindow() { InitializeComponent(); var foxDraw = new FoxDraw(canvas); var points = new List <Point>() { new Point(140, 140), new Point(160, 140), new Point(160, 160), new Point(140, 160) }; foxDraw.FillColor(Colors.Green); foxDraw.DrawPolygon(points); }
public MainWindow() { InitializeComponent(); double[][,] pointsArray = new double[3][, ] { new double[, ] { { (Width / 2) }, { 100 } }, new double[, ] { { (Width / 2) - 4 }, { 108 } }, new double[, ] { { (Width / 2) + 4 }, { 108 } } }; var foxDraw = new FoxDraw(canvas); var x = new Point(pointsArray[0][0, 0], pointsArray[0][1, 0]); var y = new Point(pointsArray[1][0, 0], pointsArray[1][1, 0]); var z = new Point(pointsArray[2][0, 0], pointsArray[2][1, 0]); var pointsoftri = new PointCollection(); pointsoftri.Add(x); pointsoftri.Add(y); pointsoftri.Add(z); Point[] zPoints = new Point[] { }; var tri = new FoxDraw(canvas); tri.StrokeColor(Colors.Red); tri.FillColor(Colors.Transparent); tri.DrawPolygon(pointsoftri); for (int i = 2; i < pointsoftri.Count; i += 2) { zPoints = new Point[] { pointsoftri[i] }; } foreach (var item in zPoints) { var j = new Point(pointsArray[2][0, 0], pointsArray[2][1, 0]); pointsoftri.Add(j); } }
public void drawhex(double a, double b) { var PointsOfHex = new PointCollection(); PointsOfHex.Add(new Point(a, b)); PointsOfHex.Add(new Point(a + 10, b)); PointsOfHex.Add(new Point(a + 14, b + 8)); PointsOfHex.Add(new Point(a + 10, b + 16)); PointsOfHex.Add(new Point(a, b + 16)); PointsOfHex.Add(new Point(a - 4, b + 8)); var Hex = new FoxDraw(canvas); Hex.FillColor(Colors.Transparent); Hex.DrawPolygon(PointsOfHex); }
public static void DrawTriangle(FoxDraw foxDraw, double startingPointX, double startingPointY, double side, bool reverseSwitch) { double height = side * Math.Sqrt(3) / 2; var points = new List <Point>(); points.Add(new Point(startingPointX, startingPointY)); points.Add(new Point(startingPointX += side, startingPointY)); if (reverseSwitch) { points.Add(new Point(startingPointX -= side / 2, startingPointY -= height)); } else { points.Add(new Point(startingPointX -= side / 2, startingPointY += height)); } foxDraw.StrokeColor(Colors.Black); foxDraw.DrawPolygon(points); }
private void TriangleFractals(FoxDraw foxDraw, int level, Point leftPoint, Point rightPoint, Point bottomPoint) { if (level == 0) { foxDraw.DrawPolygon(new List <Point> { leftPoint, rightPoint, bottomPoint }); foxDraw.SetFillColor(RandomColor()); } else { Point leftMid = new Point((bottomPoint.X + leftPoint.X) / 2, (bottomPoint.Y + leftPoint.Y) / 2); Point rightMid = new Point((bottomPoint.X + rightPoint.X) / 2, (bottomPoint.Y + rightPoint.Y) / 2); Point topMid = new Point((leftPoint.X + rightPoint.X) / 2, (leftPoint.Y + rightPoint.Y) / 2); TriangleFractals(foxDraw, level - 1, rightMid, bottomPoint, leftMid); TriangleFractals(foxDraw, level - 1, leftMid, leftPoint, topMid); TriangleFractals(foxDraw, level - 1, rightMid, topMid, rightPoint); } }
public void DrawHexagon(Point centerCoords, double hexaWholeHeight) { FoxDraw foxDraw = new FoxDraw(canvas); double hexaHeight = hexaWholeHeight / 2; double aSide = Math.Sqrt(4 / 3 * hexaHeight * hexaHeight); List <Point> polygonPoints = new List <Point>(); foxDraw.StrokeColor(Colors.Purple); foxDraw.FillColor(Colors.Transparent); polygonPoints.Add(new Point(centerCoords.X - aSide, centerCoords.Y)); polygonPoints.Add(new Point(centerCoords.X - aSide / 2, centerCoords.Y - hexaHeight)); polygonPoints.Add(new Point(centerCoords.X + aSide / 2, centerCoords.Y - hexaHeight)); polygonPoints.Add(new Point(centerCoords.X + aSide, centerCoords.Y)); polygonPoints.Add(new Point(centerCoords.X + aSide / 2, centerCoords.Y + hexaHeight)); polygonPoints.Add(new Point(centerCoords.X - aSide / 2, centerCoords.Y + hexaHeight)); foxDraw.DrawPolygon(polygonPoints); }
public void DrawTriangle(double aSide, Point center) { FoxDraw foxDraw = new FoxDraw(canvas); foxDraw.FillColor(Colors.Transparent); foxDraw.StrokeColor(Colors.Purple); double height = aSide * Math.Sqrt(3) / 2; Point leftPoint = new Point(center.X - aSide / 2, center.Y - height / 3); Point rightPoint = new Point(center.X + aSide / 2, center.Y - height / 3); Point middlePoint = new Point(center.X, center.Y + height * 2 / 3); List <Point> poly = new List <Point>(); poly.Add(leftPoint); poly.Add(rightPoint); poly.Add(middlePoint); foxDraw.DrawPolygon(poly); }
public static void DrawTriangle(FoxDraw drawer, int level, Point pointA, Point pointB, Point pointC) { if (level == 0) { List <Point> pointTriangle = new List <Point>(); pointTriangle.Add(pointA); pointTriangle.Add(pointB); pointTriangle.Add(pointC); drawer.FillColor(Colors.White); drawer.DrawPolygon(pointTriangle); } else { Point pointD = new Point((pointA.X + pointB.X) / 2f, (pointA.Y + pointB.Y) / 2f); Point pointE = new Point((pointB.X + pointC.X) / 2f, (pointB.Y + pointC.Y) / 2f); Point pointF = new Point((pointC.X + pointA.X) / 2f, (pointC.Y + pointA.Y) / 2f); DrawTriangle(drawer, level - 1, pointA, pointD, pointF); DrawTriangle(drawer, level - 1, pointD, pointB, pointE); DrawTriangle(drawer, level - 1, pointF, pointE, pointC); } }
public void DrawBrutalTriangle(FoxDraw foxDraw, int level, Point topPoint, Point leftPoint, Point rightPoint) { if (level == 0) { Point[] points = { topPoint, leftPoint, rightPoint }; foxDraw.DrawPolygon(points, Brushes.Black); } else { Point leftMid = new Point( (topPoint.X + leftPoint.X) / 2f, (topPoint.Y + leftPoint.Y) / 2f); Point rightMid = new Point( (topPoint.X + rightPoint.X) / 2f, (topPoint.Y + rightPoint.Y) / 2f); Point bottomMid = new Point( (leftPoint.X + rightPoint.X) / 2f, (leftPoint.Y + rightPoint.Y) / 2f); DrawBrutalTriangle(foxDraw, level - 1, topPoint, leftMid, rightMid); DrawBrutalTriangle(foxDraw, level - 1, leftMid, leftPoint, bottomMid); DrawBrutalTriangle(foxDraw, level - 1, rightMid, bottomMid, rightPoint); } }