programs/swirls.toby
author Ryan C. Gordon <icculus@icculus.org>
Tue, 18 Mar 2008 02:05:22 +0000
changeset 499 96e88f292dc8
parent 1 d7cb562e4e24
permissions -rw-r--r--
Updated Lua from 5.1.1 to 5.1.3.
icculus@1
     1
number r = 0.0
icculus@1
     2
number g = 0.0
icculus@1
     3
number b = 0.0
icculus@1
     4
icculus@1
     5
function main() returns nothing
icculus@1
     6
	//doTopLeftFan()
icculus@1
     7
	doDragon()
icculus@1
     8
endfunction
icculus@1
     9
icculus@1
    10
function doTopLeftFan() returns nothing
icculus@1
    11
	setTurtleXY(10, 100)
icculus@1
    12
	setAngle(90)
icculus@1
    13
	fanLeft(175, 10)
icculus@1
    14
endfunction
icculus@1
    15
icculus@1
    16
function fanLeft(number distance, number angle) returns nothing
icculus@1
    17
	if (distance >= 0)
icculus@1
    18
		goForward(distance)
icculus@1
    19
		goBackward(distance - 10)
icculus@1
    20
		turnLeft(angle)
icculus@1
    21
		fanLeft(distance - 5, angle)
icculus@1
    22
	endif
icculus@1
    23
endfunction
icculus@1
    24
icculus@1
    25
function doDragon() returns nothing
icculus@1
    26
	rightDragon(20, 3)
icculus@1
    27
endfunction
icculus@1
    28
icculus@1
    29
function leftDragon(number iteration, number dist) returns nothing
icculus@1
    30
	r = r + 0.001
icculus@1
    31
	if (r > 1.0)
icculus@1
    32
		r = 0.0
icculus@1
    33
	endif
icculus@1
    34
	setPenColorRGB(r, g, b)
icculus@1
    35
	if (iteration == 0)
icculus@1
    36
		g = g + 0.01
icculus@1
    37
		if (g > 1.0)
icculus@1
    38
			g = 0.0
icculus@1
    39
		endif
icculus@1
    40
		goForward(dist)
icculus@1
    41
	else
icculus@1
    42
		leftDragon(iteration - 1, dist)
icculus@1
    43
		turnLeft(90)
icculus@1
    44
		rightDragon(iteration - 1, dist)
icculus@1
    45
	endif
icculus@1
    46
endfunction
icculus@1
    47
icculus@1
    48
icculus@1
    49
function rightDragon(number iteration, number dist) returns nothing
icculus@1
    50
	b = b + 0.001
icculus@1
    51
	if (b > 1.0)
icculus@1
    52
		b = 0.0
icculus@1
    53
	endif
icculus@1
    54
	setPenColorRGB(r, g, b)
icculus@1
    55
	if (iteration == 0)
icculus@1
    56
		g = g + 0.01
icculus@1
    57
		if (g > 1.0)
icculus@1
    58
			g = 0.0
icculus@1
    59
		endif
icculus@1
    60
		goForward(dist)
icculus@1
    61
	else
icculus@1
    62
		leftDragon(iteration - 1, dist)
icculus@1
    63
		turnRight(90)
icculus@1
    64
		rightDragon(iteration - 1, dist)
icculus@1
    65
	endif
icculus@1
    66
endfunction
icculus@1
    67
icculus@1
    68
icculus@1
    69