Sierpinski curve: Difference between revisions
Content added Content deleted
(Added solution for Action!) |
|||
Line 1,359: | Line 1,359: | ||
var Game = SierpinskiCurve.new(770, 770, 5, Color.blue, Color.yellow)</lang> |
var Game = SierpinskiCurve.new(770, 770, 5, Color.blue, Color.yellow)</lang> |
||
=={{header|Yabasic}}== |
|||
<lang Yabasic>// Rosetta Code problem: http://rosettacode.org/wiki/Sierpinski_curve |
|||
// Adapted from https://www.ocg.at/sites/ocg.at/files/EuroLogo2001/P74Batagelj.pdf to Yabasic by Galileo, 01/2022 |
|||
import turtle |
|||
sub Sierp(n, a, h, k) |
|||
if n = 0 move(k) : return |
|||
turn(a) : Sierp(n - 1, -a, h, k) : turn(-a) : move(h) |
|||
turn(-a) : Sierp(n - 1, -a, h, k) : turn(a) |
|||
end sub |
|||
sub Sierpinski(n, d) |
|||
local i |
|||
pen(false) |
|||
goxy(10, 680) |
|||
pen(true) |
|||
color 255, 255, 0 |
|||
for i = 1 to 4 |
|||
Sierp(n, 45, d/sqrt(2), 5*d/6) |
|||
turn(45) |
|||
move(d/sqrt(2)) |
|||
turn(45) |
|||
next |
|||
end sub |
|||
startTurtle() |
|||
Sierpinski(9, 12) </lang> |
|||
=={{header|zkl}}== |
=={{header|zkl}}== |