Pythagoras tree: Difference between revisions

Content added Content deleted
m (→‎{{header|Rust}}: syntaxhighlight lang="rust")
Line 413: Line 413:
[https://easylang.online/apps/_pythagoras-tree.html Run it]
[https://easylang.online/apps/_pythagoras-tree.html Run it]


<syntaxhighlight lang="text">func tree x1 y1 x2 y2 depth . .
<syntaxhighlight lang="text">
if depth < 8
func tree x1 y1 x2 y2 depth . .
dx = x2 - x1
if depth < 8
dy = y1 - y2
dx = x2 - x1
x3 = x2 - dy
dy = y1 - y2
y3 = y2 - dx
x3 = x2 + dy
x4 = x1 - dy
y3 = y2 + dx
y4 = y1 - dx
x4 = x1 + dy
x5 = x4 + 0.5 * (dx - dy)
y4 = y1 + dx
y5 = y4 - 0.5 * (dx + dy)
x5 = x4 + 0.5 * (dx + dy)
color3 0.3 0.2 + depth / 18 0.1
y5 = y4 + 0.5 * (dx - dy)
polygon [ x1 y1 x2 y2 x3 y3 x4 y4 ]
color3 0.3 0.2 + depth / 18 0.1
polygon [ x3 y3 x4 y4 x5 y5 ]
polygon [ x1 y1 x2 y2 x3 y3 x4 y4 ]
call tree x4 y4 x5 y5 depth + 1
polygon [ x3 y3 x4 y4 x5 y5 ]
call tree x5 y5 x3 y3 depth + 1
call tree x4 y4 x5 y5 depth + 1
call tree x5 y5 x3 y3 depth + 1
.
.
.
.
call tree 41 10 59 10 0
color3 0.3 0 0.1
call tree 41 90 59 90 0</syntaxhighlight>
</syntaxhighlight>


=={{header|F_Sharp|F#}}==
=={{header|F_Sharp|F#}}==