it’s not that simple
initially mouseX,mouseY is 0,0, so the initial line appears.
you can use the if-command to avoid this initial line:
void setup() {
size(600, 800);
background(20, 40, 80);
}
void draw() {
stroke(30, 200, 100, 40);
if (mouseX>0 && mouseY>0) { // !!!!!!!!!!!!!!!!
line(300, 30, mouseX, mouseY );
}
}
void mousePressed() {
if (mouseButton==RIGHT) {
background (20, 190, 220);
}
}
//void keyPressed(){background(100,20,10);}
====================================================================
OR
use if(mousePressed) instead, so you need to hold the mouse to draw.
- then you want to use the RIGHT mouse button to clear the screen (see function mousePressed()).
void setup() {
size(600, 800);
background(20, 40, 80);
}
void draw() {
stroke(30, 200, 100, 40);
if (mousePressed) { // !!!!!!!!!!!!!!!!!!!!!!!!!!!!
line(300, 30, mouseX, mouseY );
}
}
void mousePressed() {
if (mouseButton==RIGHT) { // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
background (20, 190, 220);
}
}
//void keyPressed(){background(100,20,10);}