Examples updates for 2.0

This commit is contained in:
Casey Reas
2011-07-17 06:50:01 +00:00
parent d996b52e66
commit 84dd359b1e
33 changed files with 305 additions and 280 deletions
+13 -31
View File
@@ -5,43 +5,25 @@
* The "mouseX" variable is used to control both the
* size and color of the rectangles.
*/
int gx = 15;
int gy = 35;
float leftColor = 0.0;
float rightColor = 0.0;
void setup() {
size(200, 200);
colorMode(RGB, 1.0);
size(640, 360);
noStroke();
colorMode(RGB, height, height, height);
rectMode(CENTER);
}
void draw() {
background(0.0);
update(mouseX);
fill(0.0, leftColor + 0.4, leftColor + 0.6);
rect(width/4-gx, height/2-gx, gx*2, gx*2);
fill(0.0, rightColor + 0.2, rightColor + 0.4);
rect(width/1.33-gy, height/2-gy, gy*2, gy*2);
float r1 = map(mouseX, 0, width, 0, height);
float r2 = height-r1;
fill(r1);
rect(width/2 + r1/2, height/2, r1, r1);
fill(r2);
rect(width/2 - r2/2, height/2, r2, r2);
}
void update(int x) {
leftColor = -0.002 * x/2 + 0.06;
rightColor = 0.002 * x/2 + 0.06;
gx = x/2;
gy = 100-x/2;
if (gx < 10) {
gx = 10;
} else if (gx > 90) {
gx = 90;
}
if (gy > 90) {
gy = 90;
} else if (gy < 10) {
gy = 10;
}
}