Last active
March 15, 2022 17:12
-
-
Save claytical/dccb55a237307910ef0bd5d5475ddec2 to your computer and use it in GitHub Desktop.
Processing, Line Drawing Program With Conditional Colors, Default Stroke Width
This file contains hidden or 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 | |
int r = 0; | |
int g = 0; | |
int b = 0; | |
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) { | |
lineDraw(5); | |
} | |
} | |
} | |
void lineDraw(int numberOfLines) { | |
strokeWeight(5); | |
for (int i = 0; i < numberOfLines; i++) { | |
stroke(r, g, b); | |
line(pmouseX + (i * 5), pmouseY+ (i * 5), mouseX+ (i * 5), mouseY+ (i * 5)); | |
} | |
r = r + 1; | |
g = g + 30; | |
b = g + 70; | |
if (r > 255) { | |
r = 0; | |
} | |
if (g > 255) { | |
g = 0; | |
} | |
if (b > 255) { | |
b = 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment