Skip to content

Commit b0e18a9

Browse files
committed
Eliptical branches
1 parent 3ff962d commit b0e18a9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

FractalTrees/Tree.fs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,17 @@ let drawTree file =
1818
let x = length * Math.Sin(direction)
1919
let y = length * Math.Cos(direction)
2020
let nextX, nextY = startX + x, startY + y
21+
let width = length / 15.
22+
let widthX = width * Math.Cos(direction)
23+
let widthY = width * Math.Sin(direction)
24+
25+
let points =
26+
[| new Point(int (startX - widthX), int (startY - widthY));
27+
new Point(int (nextX - widthX), int (nextY - widthY));
28+
new Point(int (nextX + widthX), int (nextY + widthY));
29+
new Point(int (startX + widthX), int (startY + widthY)) |]
2130
let pen = new Pen(Color.Black, float32 length / 15.f)
22-
g.DrawLine(pen, int startX, int startY, int nextX, int nextY)
31+
g.FillClosedCurve(new SolidBrush(Color.Black), points)
2332
(nextX, nextY)
2433

2534
let largeAngle = Math.PI / 2.4

0 commit comments

Comments
 (0)