Pythagoras tree: Difference between revisions

m
m (→‎{{header|Wren}}: Changed to Wren S/H)
m (→‎{{header|Dart}}: cosmetics)
 
(2 intermediate revisions by the same user not shown)
Line 453:
final (a, b) = pp;
final v = Point((b - a).y, (a - b).x);
final ([c, d), e] = [a, b, (a + b + v,) b* 0.5].map((p) => p + v).toList();
final e = (c + d + v) * 0.5;
basis.addAll([(c, e), (e, d)]);
return '<polygon points="${[a, c, e, d, c, d, b].expand((p) => [p.x, p.y]).join(' ')}"/>';
Line 491 ⟶ 490:
for (var (a, b) in basis0) {
final v = Offset((b - a).dy, (a - b).dx);
final ([c, d), e] = [a, b, (a + b + v,) b/ 2].map((p) => p + v).toList();
final e = (c + d + v) / 2;
basis.addAll([(c, e), (e, d)]);
path.addPolygon([a, c, e, d, c, d, b], true);
Line 1,041 ⟶ 1,039:
</html></syntaxhighlight>
==={{trans|Rust}}===
[[File:PythagorTree-scrinPythagorTreeJS.pngsvg|400px]]<br>
Run this script from the browser console (F12) or from the <script> tag of an html document.
<syntaxhighlight lang="javascript">let base = [[{ x: -200, y: 0 }, { x: 200, y: 0 }]];
Line 2,098 ⟶ 2,096:
=={{header|Rust}}==
Creates a '''[https://gist.githubusercontent.com/vvshard/833bd69acfa9160350cdbc9b57bbefe4/raw/pythagoras_tree.svg svg file]''' (12 levels) <br>
[[File:PythagorTree-scrinPythagoras_tree.pngsvg]]
 
'''[dependencies]'''<br>
106

edits