Created
March 15, 2022 17:14
-
-
Save claytical/78254fc8694951b785db8326f0f18681 to your computer and use it in GitHub Desktop.
Processing, Line Drawing Program, Conditional Statements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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