Skip to content

Instantly share code, notes, and snippets.

@claytical
Created March 15, 2022 17:13
Show Gist options
  • Save claytical/7f940b15e7a2b1483b07932fd29099a7 to your computer and use it in GitHub Desktop.
Save claytical/7f940b15e7a2b1483b07932fd29099a7 to your computer and use it in GitHub Desktop.
Processing, Line Drawing Program, Loop Function
//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);
lineDraw(5);
}
}
}
void lineDraw(int numberOfLines) {
for (int i = 0; i < numberOfLines; i++) {
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