Created
January 27, 2015 13:12
-
-
Save CSchoel/2423291d02909dfcab09 to your computer and use it in GitHub Desktop.
Demonstration of for-loop with moving lines
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
//Autor: Christopher Schölzel | |
float x1,y1; //erster Punkt für unteres Linienende | |
float x2,y2; //zweiter Punkt für unteres Linienende | |
void setup() { | |
size(400,400); | |
x1 = 0; | |
y1 = height; | |
x2 = width; | |
y2 = height; | |
} | |
void draw() { | |
background(255); | |
stroke(0); | |
for(int i = 0; i < 100; i++) { | |
float lambda = i/100.0; //Fortschritt zw. 0 und 1 | |
float cx2 = x1+lambda*(x2-x1); | |
float cy2 = y1+lambda*(y2-y1); | |
line(width*lambda,0,cx2,cy2); | |
} | |
} | |
void mouseMoved() { | |
x1 = width-mouseX; | |
x2 = mouseX; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment