Skip to content

Instantly share code, notes, and snippets.

@jshaw
Created July 27, 2012 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jshaw/3190440 to your computer and use it in GitHub Desktop.
Save jshaw/3190440 to your computer and use it in GitHub Desktop.
Draw and Drip (processing)
<!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