Altering the effects of mousePressed.
in
Programming Questions
•
2 years ago
I would like to know how to change the effects of mousePressed in my program. It's a simple program where when mouse is pressed it draws a random fuzzy grouping of lines. (think of the old doodle boards). I would like to be able to change this to a single line when a key is pressed and then back if another is pressed.....? Any Ideas? Also I am would like to make it so you can cycle through the background images, not just random. see code below to see how it works so far and thank you in advance.
int grow = 0;
void setup()
{
size(600,600);
PImage fragment;
float a= random(1,6);
int fragNumber = int (a);
fragment = loadImage ("img_" + fragNumber + ".jpg");
image(fragment, 0, 0, 600, 600);
}
void draw() {
stroke(0); // this is the pen tool!
if(mousePressed) {
grow++;
// strokeWeight(grow);
line(mouseX + random(-10,10), mouseY + random(-10,10), mouseX + random(-5,5), mouseY + random(-5,5));
} else{grow= 0;}
}
int grow = 0;
void setup()
{
size(600,600);
PImage fragment;
float a= random(1,6);
int fragNumber = int (a);
fragment = loadImage ("img_" + fragNumber + ".jpg");
image(fragment, 0, 0, 600, 600);
}
void draw() {
stroke(0); // this is the pen tool!
if(mousePressed) {
grow++;
// strokeWeight(grow);
line(mouseX + random(-10,10), mouseY + random(-10,10), mouseX + random(-5,5), mouseY + random(-5,5));
} else{grow= 0;}
}
1