SpinCNgon — ProgramsLOGO
last changed 29 May 2008
 

SpinCNgon









to SPIN :n :rad :slice :times :angle
SPINCNGON :n :rad :slice :times :angle
lt :times * :angle
end

to SPINCNGON :n :rad :slice :times :angle
if (:slice * :times > :rad) [set :times :rad / :slice + 1]
if :times < 1 [stop]
CNGON :n :rad
rt :angle
SPINCNGON :n (:rad - :slice) :slice (:times - 1) :angle
end

to CONGON :n :rad :slice :times
if (:slice * :times > :rad) [set :times :rad / :slice + 1]
if :times < 1 [stop]
CNGON :n (abs :rad)
CONGON :n (:rad - :slice) :slice (:times - 1)
end

to SPINGON :sides :length :angle
let [ :t 360 / :angle ]
repeat :t [
setc random 300
NGON :sides :length
lt :angle
]
end

to CNGON :sides :radius
pu fd :radius lt 90 + 180 / :sides pd
NGON :sides ((sin 180 / :sides) * :radius * 2)
pu rt 90 + 180 / :sides bk :radius pd
end

to NGON :sides :length
repeat :sides [
fd :length lt 360 / :sides
]
end
1