Skip to content

Instantly share code, notes, and snippets.

@claytical
Created March 15, 2022 17:11
Show Gist options
  • Save claytical/10db8d316d7188b7cca3ac2359b122fa to your computer and use it in GitHub Desktop.
Save claytical/10db8d316d7188b7cca3ac2359b122fa to your computer and use it in GitHub Desktop.
Processing, Line Drawing Program Looped Gradient Greens
//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) {
lineDraw(5);
}
}
}
void lineDraw(int numberOfLines) {
for (int i = 0; i < numberOfLines; i++) {
float scaledColorValue = map(i, 0, numberOfLines, 0, 255);
stroke(scaledColorValue, 255, 150);
line(pmouseX + (i * 5), pmouseY+ (i * 5), mouseX+ (i * 5), mouseY+ (i * 5));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment