This Genie will draw a Fibonacci spiral pattern resembling Sunflower seeds. Algorithm from Barrett & Mackay, "Spatial Structure & the Microcomputer". Written by Don Cox.
*/
/* $VER: SunFlower Apr 94 */
msg = PDSetup.rexx(2,0)
units = getclip(pds_units)
if msg ~= 1 then exit_msg(msg)
numeric digits 8
call PDM_setbatchmode(0)
call PDM_autoupdate(0)
pi = 3.14159
pi2 = 6.28318
cr = '0a'x
psize = pdm_GetPageSize()
pageX = word(psize,1)
pageY = word(psize,2)
scale = getclip(pduserscale)
numberofseeds = getclip(pdusernumberofseeds)
if scale = '' then scale = 0.5
if numberofseeds = '' then numberofseeds = 160
call pdm_unselectobj()
man = pdm_getform("SunFlower Specifications",4,"Seeds:"numberofseeds ||cr|| "Scale Factor:"scale )
if man = '' then exit_msg()
parse var man numberofseeds '0a'x scale
if ~(datatype(numberofseeds,n) & datatype(scale, n)) then exit_msg("Invalid Entry")
call setclip(pduserscale, scale)
call setclip(pdusernumberofseeds, numberofseeds)
curcolor = pdm_GetFillPattern()
parse var curcolor type '0a'x curcolor
color = pdm_SetFillPattern(,1,"Yellow")
color = pdm_SetFillPattern(,1)
parse var color filler '0a'x color '0a'x filler
if color = '' then exit_msg("No colour selected")
call pdm_setfillpattern(,1,color,)
color = pdm_getcolordata(color)
red = word(color,1)
green = word(color,2)
blue = word(color,3)
b = pdm_getclickposn("Where do you want the center?")
posx = word(b,1)
posy = word(b,2)
call pdm_ShowStatus(" Working...")
t = (1+squareroot(5))/2
th = 2*pi/t
radius2 = scale*t/2
call pdm_UnselectObj()
identity = 1
do i=1 to numberofseeds
r =scale* squareroot(i)
theta = th*i
x = (r * sin(theta))+posx
y = (r * cos(theta))+posy
if (x<0 | y<0 | x>pageX | y>pageY) then iterate /* don't draw off edge of page */