Draw and Drip (processing)
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
<!doctype html> | |
<html> | |
<head> | |
<script type="text/javascript" src="processing.js"></script> | |
</head> | |
<body> | |
<div class="learning-demo"> | |
<script type="application/processing"> | |
int value = 0; | |
int x = 0; | |
int y = 0; | |
int x2 = 0; | |
int y2 = 0; | |
int r = 0; | |
int rLine = 0; | |
int drawTo = 0; | |
int hmx = 0; | |
int hmy = 0; | |
int hpmx = 0; | |
int hpmouseY = 0; | |
void setup() { | |
size(1200,600); | |
frameRate(30); | |
} | |
void draw() { | |
fill(value); | |
rect(25, 25, 50, 50); | |
strokeWeight(10.0); | |
strokeJoin(ROUND); | |
//println("tdrawTo " + drawTo); | |
if (r == 2 ) { | |
//drawTo = hmy + rLine; | |
//animateLine(mouseX, mouseY, drawTo); | |
println("****************** r " + hmx + " " + hmy + " " + hpmx + " " + hpmouseY); | |
HLine dLine = new HLine(hmx, hmy, drawTo); | |
} | |
} | |
void mouseDragged() { | |
r = ceil( random(4) ); | |
rLine = ceil( random(100) ); | |
hmx = mouseX; | |
hmy = mouseY; | |
hpmx = pmouseX; | |
hpmouseY = pmouseY; | |
line(mouseX, mouseY, pmouseX, pmouseY); | |
} | |
class HLine { | |
HLine (mx, my, drawTo) { | |
linespeed = 0.1; | |
endy = my; | |
drawTo = my + rLine; | |
println("++++++++++++ " + + mx + " " + my + " " + drawTo ); | |
println("++++++++++++ " + + mx + " " + my + " " + drawTo ); | |
println("++++++++++++ " + + endy + " " + drawTo ); | |
// println("linespeed " + this.linespeed); | |
// println("endy " + this.endy); | |
while(endy < drawTo) { | |
// println("this.draw to " + this.drawTo); | |
// println("this.endy " + this.endy); | |
//line(0, 0, endx, 0); | |
line(hmx, hmy, hmx, endy); | |
endy += linespeed; | |
} | |
} | |
} | |
</script> | |
<canvas width="1200" height="600"></canvas> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment