// use globally available functions to:
setBackgroundColor(.6, 0, 0);
setPenColor(.8, .5, .3);
setPenWeight(.01);
//
define the function of drawing a dandelion
function Dandelion(scale, x, y) //scale: how big the dandelion
is (0-1); x,y: the center of it (0-1)
{
@@for
(i=0; i<scale*50; i++)
@@{
@@@@var px = ((math.random()-.5)*scale+x);
//px,py: the end point of main stem
@@@@if ( px+scale/10>1
)
@@@@{
@@@@@@px=2-scale/5-px;
@@@@}
@@@@else if (px-scale/10<0
)
@@@@{
@@@@@@px=scale/5-px;
@@@@}
@@@@var py = ((math.random()-.5)*scale+y);
@@@@if ( py+scale/10>1
)
@@@@{
@@@@@@py=2-scale/5-py;
@@@@}
@@@@else if (py-scale/10<0
)
@@@@{
@@@@@@py=scale/5-py;
@@@@}
@@@@setPenWeight(.0125*math.sqrt(scale));
@@@@drawLine(x, y,
px, py); //draw the main stem
@@@@setPenWeight(.01*math.sqrt(scale));
@@@@drawLine(px, py,
px+scale*(math.random()/10-.05), py+scale*(math.random()/10-.05)); //draw
the little tip
@@}
}
//define
the function of drawing multiple dandelions
function Dandelions (howmany) //howmany: how many of them
{
@@for (j=0; j<howmany; j++)
@@{
@@@@setPenColor(.8+(math.random()-.5)*.1,
.5+(math.random()-.5)*.3, .3+(math.random()-.5)*.2);
@@@@var oneflower=math.random()/10*8+.1;
@@@@Dandelion( oneflower,
math.random(), math.random() );
@@}
}
//
call the function of dandelion
Dandelions(6);
//
stop playback head to prevent continuous redrawing
stop();
On the button:
on(release)
{
@@Dandelions(2);
}

