Weeee! .. I've got a shiny new copy of Emergence, so I'm just getting around to playing with it .. :)
I've been mostly using Creative, so I thought I'd try something easy by porting one or two programs across.
This is my Picasso random images program. You can try playing around with the initialisation parameters, to get varying effects.
' Emergence Basic code
' Picasso Patterns ..
' GWS - 2009
window w
int run,maxsteps,wstyle
int cx,cy,t,ptype,pause
int i,red,grn,blu
float pi,twopi,d2r
float x1,y1,x2,y2
float k,r,inc,delta,theta
autodefine "OFF"
pi = 4 * fatan(1) : ' gives an accurate value of pi (3.1419 ..)
twopi = 2 * pi
d2r = pi / 180 : ' degree to radian conversion
wstyle = @SIZE|@MINBOX|@MAXBOX
openwindow w, 0, 0, 800, 600, wstyle, 0, "Picasso", &msghandler
setwindowcolor w,rgb(0,0,60)
control w, @button,"Exit", 500, 500, 70, 30, @ctlbtnflat, 1
setcontrolcolor w, 1, 0, rgb(120,140,220)
control w, @button,"Pause", 220, 500, 70, 30, @ctlbtnflat, 2
setcontrolcolor w, 2, 0, rgb(120,140,220)
maxsteps = 200
gosub initialise
cx = 400
cy = 250
pause = 0 : ' pause flag
gosub draw
starttimer w,3000,1 : ' refresh the pattern every 3 seconds ...
run = 1
waituntil run = 0
stoptimer w,1
closewindow w
end
SUB msghandler
select @class
case @idclosewindow
run = 0
case @idcreate
centerwindow w
case @idcontrol
select @CONTROLID
case 1
' click the Exit button ...
run = 0
case 2
' click the pause button ..
if (pause = 0)
pause = 1 :' set pause flag
setcontroltext w,2,"Continue"
else
pause = 0 :' continue
setcontroltext w,2,"Pause"
endif
endselect
case @idtimer
if (pause = 0)
gosub initialise
gosub draw
endif
endselect
ENDSUB
SUB draw
move w,cx,cy
while (r <= maxsteps)
r = r + inc
SETLINESTYLE w, @LSSOLID, int(1 + r / k) :' line size
theta = theta + delta
' set the drawing color for this step ..
red = 127.5 * (1 + fcos(theta))
grn = 127.5 * (1 + fcos(theta + twopi/3))
blu = 127.5 * (1 + fcos(theta + 2 * twopi/3))
for i = 1 to ptype-1
x1 = cx + r * fcos(theta + i * twopi/ptype)
y1 = cy + r * fsin(theta + i * twopi/ptype)
lineto w,x1,y1,rgb(red,grn,blu)
next i
endwhile
ENDSUB
SUB initialise
' set start values for a drawing ..
' clear the screen ..
rect w,0,0,800,600,0,rgb(0,0,60)
r = 0.0
theta = RND(100.0)
' set pattern type ..
ptype = RAND(2,6)
' increments within maxsteps ..
inc = RND(2.0,30.0)
' angular increment ..
delta = RND(1.5,30.0) * d2r
' line thickness ..
k = RND(20,100)
ENDSUB
all the best, :)
Graham