loso25 wrote on Mar 18th, 2010, 1:47am:so basically everything I've done in "mousePressed" I need to move to "Draw"
Where did I wrote that
To be clearer, remove all the "float" declarations from mousePressed.
To be even more clearer, it is not enough because you don't use r, g, b in draw(). Here is a tested version:
Code:int x = 200;
int y = 150;
float r = random (255);
float g = random (255);
float b = random (255);
float radius = random (20,79);
void setup () {
size (400, 300);
}
void draw ()
{
background (255);
stroke (160);
line (width/2, 0, width/2, height);
line (0, height/2, width, height/2);
fill (r, g, b);
stroke (255);
ellipse (x, y, 100, 100);
y = y + 1;
}
void mousePressed ()
{
background (255);
y = mouseY + 1;
x = mouseX + 1;
r = random (255);
g = random (255);
b = random (255);
radius = random (20, 79);
}
You had no trail because of the white stroke clearing the previous position of the circle (because you move at 1 pixel per frame). Yet the advice to use background() at start of draw() is generally useful (unless you want special effects).
Note also I have put constants in size(), as advised by the reference: this information is used when you export the sketch.