-
-
Save jkwok91/b7da85a6b224132112b6 to your computer and use it in GitHub Desktop.
yeuch
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
/* | |
click and start line | |
click and end line | |
*/ | |
boolean lineStarted, lineFinished; | |
PVector p0, p1; | |
void setup() { | |
size(300, 300); | |
background(0); | |
stroke(255); | |
lineStarted = false; | |
lineFinished = false; | |
} | |
void draw() { | |
background(0); | |
if (lineFinished) { | |
line(p0.x, p0.y, p1.x, p1.y); | |
} | |
else if (lineStarted) { | |
line(p0.x, p0.y, mouseX, mouseY); | |
} | |
} | |
void mousePressed() { | |
if (!lineStarted && !lineFinished) { | |
p0 = new PVector(mouseX, mouseY); | |
lineStarted = true; | |
lineFinished = false; | |
} | |
else if (lineStarted) { | |
p1 = new PVector(mouseX, mouseY); | |
lineStarted = false; | |
lineFinished = true; | |
} | |
else { | |
lineFinished = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment