/
swirls.toby
69 lines (59 loc) · 1.15 KB
/
swirls.toby
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
number r = 0.0
number g = 0.0
number b = 0.0
function main() returns nothing
//doTopLeftFan()
doDragon()
endfunction
function doTopLeftFan() returns nothing
setTurtleXY(10, 100)
setAngle(90)
fanLeft(175, 10)
endfunction
function fanLeft(number distance, number angle) returns nothing
if (distance >= 0)
goForward(distance)
goBackward(distance - 10)
turnLeft(angle)
fanLeft(distance - 5, angle)
endif
endfunction
function doDragon() returns nothing
rightDragon(20, 3)
endfunction
function leftDragon(number iteration, number dist) returns nothing
r = r + 0.001
if (r > 1.0)
r = 0.0
endif
setPenColorRGB(r, g, b)
if (iteration == 0)
g = g + 0.01
if (g > 1.0)
g = 0.0
endif
goForward(dist)
else
leftDragon(iteration - 1, dist)
turnLeft(90)
rightDragon(iteration - 1, dist)
endif
endfunction
function rightDragon(number iteration, number dist) returns nothing
b = b + 0.001
if (b > 1.0)
b = 0.0
endif
setPenColorRGB(r, g, b)
if (iteration == 0)
g = g + 0.01
if (g > 1.0)
g = 0.0
endif
goForward(dist)
else
leftDragon(iteration - 1, dist)
turnRight(90)
rightDragon(iteration - 1, dist)
endif
endfunction