programs/triangleWeb.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
function main() returns nothing
icculus@1
     2
	number top = getTurtleSpaceWidth()
icculus@1
     3
	if (top < getTurtleSpaceHeight())
icculus@1
     4
		top = getTurtleSpaceHeight()
icculus@1
     5
	endif
icculus@1
     6
icculus@1
     7
	disableFence()
icculus@1
     8
	setPenColor(8)
icculus@1
     9
	spiderWeb(top, top * 0.03, top * 0.15)
icculus@1
    10
endfunction
icculus@1
    11
icculus@1
    12
function spiderWeb(number max, number min, number increment) returns nothing
icculus@1
    13
	number i
icculus@1
    14
icculus@1
    15
	if (increment > 0.0)
icculus@1
    16
		increment = increment * -1.0
icculus@1
    17
	endif
icculus@1
    18
icculus@1
    19
	for i = max downto min step increment
icculus@1
    20
		triangleWheel(i, 12)
icculus@1
    21
	endfor
icculus@1
    22
endfunction
icculus@1
    23
icculus@1
    24
icculus@1
    25
function triangleWheel(number size, number angle) returns nothing
icculus@1
    26
	number i
icculus@1
    27
icculus@1
    28
	for i = 1 to 360 / angle
icculus@1
    29
		isosceles(size)
icculus@1
    30
		turnRight(angle)
icculus@1
    31
	endfor
icculus@1
    32
endfunction
icculus@1
    33
icculus@1
    34
icculus@1
    35
function isosceles(number size) returns nothing
icculus@1
    36
	number i
icculus@1
    37
icculus@1
    38
	for i = 1 to 3
icculus@1
    39
		goForward(size)
icculus@1
    40
		turnRight(120)
icculus@1
    41
	endfor
icculus@1
    42
endfunction
icculus@1
    43
icculus@1
    44
icculus@1
    45