INgon — ProgramsLOGO
last changed 3 June 2008
 

INgon















to triangles :rad :lev
if :lev < 1 [CNGON 3 :rad stop]
repeat 3 [
pu fd :rad / 2 pd
TRIANGLES (:rad / 2) (:lev - 1)
pu bk :rad / 2 pd rt 120
]
end

to squares :rad :lev
if :lev < 1 [CNGON 4 :rad stop]
repeat 4 [
pu fd :rad / 2 pd
SQUARES (:rad / 2) (:lev - 1)
pu bk :rad / 2 pd rt 90
]
end

to squares45 :rad :lev
if :lev < 1 [CNGON 4 :rad stop]
repeat 4 [
pu fd :rad / 2 pd
SQUARES45 (:rad / 2) (:lev - 1)
pu bk :rad / 2 pd rt 90
]
end

to hexagons :rad :lev
if :lev < 1 [CNGON 6 :rad stop]
repeat 6 [
pu fd :rad / 2 pd
let [ :colorp (random 14) * 10 ]
let [ :colorb (random 4) ]
setc (:colorb + :colorp)
HEXAGONS (:rad / 2) (:lev - 1)
pu bk :rad / 2 pd rt 60
]
end

to circletriangles :rad :lev
if :lev < 1 [CNGON 50 :rad stop]
repeat 3 [
pu fd :rad / 2 pd
CIRCLETRIANGLES (:rad / 2) (:lev - 1)
pu bk :rad / 2 pd rt 120
]
end

to circlesquares : rad :lev
if :lev < 1 [CNGON 50 :rad stop]
repeat 4 [
pu fd (:rad / 2) pd
CIRCLESQUARES (:rad / 2) (:lev - 1)
pu bk (:rad / 2) pd rt 90
]
end

to circlehexes :rad :lev
if :lev < 1 [CNGON 50 :rad stop]
repeat 6 [
pu fd :rad / 2 pd
; setc random 140
CIRCLEHEXES (:rad / 2) (:lev - 1)
pu bk :rad / 2 pd rt 60
]
end

to ingon :n :rad :c :lev
if :lev < 1 [stop]
if :c = 1 [CNGON 100 :rad]
CNGON :n :rad
INGON :n (cos 180 / :n) * :rad :c (:lev - 1)
end

to inbox
let [ :rad 120 ]
let [ :lev 1 ]
CNGON 100 :rad
SQUARES :rad :lev
rt 45
SQUARES ((cos 180 / 4) * :rad) :lev
end
1