Skip to content

Instantly share code, notes, and snippets.

@claytical
Created March 15, 2022 17:14
Show Gist options
  • Save claytical/78254fc8694951b785db8326f0f18681 to your computer and use it in GitHub Desktop.
Save claytical/78254fc8694951b785db8326f0f18681 to your computer and use it in GitHub Desktop.
Processing, Line Drawing Program, Conditional Statements
//draw a contiuous line
void setup() {
size(500, 500);
background(0, 0, 0);
}
void draw() {
println("Mouse X: " + mouseX + " Mouse Y: " + mouseY);
}
void mouseDragged() {
//check if the previous mouse x position was on the screen of the x axis
if (pmouseX > 0 && pmouseX < width) {
//check if the previous mouse y position was on the screen of the y axis
if (pmouseY > 0 && pmouseY < height) {
stroke(255, 255, 255);
line(pmouseX, pmouseY, mouseX, mouseY);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment