Really simple drawing sketch, how do I make it stop drawing when the mouse goes outside of the canvas?
in
Processing with Other Languages
•
1 year ago
I have this really easy sketching thingy that I'm using with processing.js. The problem is, when you use this on a webpage and people move their mouse too fast (outside the canvas) the lines get all weird and jumpy. How can I prevent this?
- void setup() {
size(320, 320);
background(255);
noStroke();
}
void draw() {
int strokeValue = $("#sliderR").slider("value");
String picker = $(".simpleColorDisplay").data('backgroundcolor');
color c = unhex("FF"+picker);
stroke(c);
strokeWeight(strokeValue);
smooth();
if (mousePressed && (mouseButton == LEFT)) {
line(pmouseX, pmouseY, mouseX, mouseY);
}
}
1