The fern and rand algorithms, I have borrowed, or perhaps stolen from Peter. But they are well disguised and hidden in a class. So he may never find out
class plant
===========
'
string s 'texture buffer
dword *p 'buffer index
dword sz 'x and y tex size
'
method particle()
static single fxx, fxy, fyx, fyy, dxx, dyy, x, y, v,px,py
'
'RND 0..100
pseed=pseed*0x8088405+1 'chaos
mov eax,101 'range 0..100
mul pseed 'edx product bits 32..63
'
select edx
case 0 to 10 'omit for dense fronds
fxx = 0
fxy = 0
fyx = 0
fyy = 0.16
dxx = 0
dyy = 0
case 10 to 86
fxx = .85 'bushy
fxy = 0.04 'curve up
fyx = -.04 'dip density
fyy = 0.85 'dispersal and internode
dxx = 0.0 '
dyy = 1.60 'height / density
case 87 to 93 'omit for right side only
fxx = 0.2
fxy = -.26
fyx = 0.23
fyy = 0.22
dxx = 0
dyy = 0.16
case 94 to 100 'omit for left side only
fxx = -.15 'x factor for x
fxy = 0.28 'y factor for x
fyx = 0.26 'x factor for y
fyy = 0.24 'y factor for y
dxx = 0 ' displacement for x
dyy = 0.44 ' displacement for y
end select
v=x 'preserve original x
x = fxx*v + fxy*y + dxx
y = fyx*v + fyy*y + dyy
px=limit(0,int(x)*24+sz*.5,sz-1)
py=limit(0,int(y)*24+00,sz-1)
p(1+px+py*sz)=0xffffffff
end method
method new(sys m,n) as sys
sz=m
s=nuls m*m*4
@p=strptr s
sys i
for i=1 to n 'typically 64000
Particle
next
return @p
end method
method free()
s="" : @p=0
end method
'
end classX