Examples updates to 640 x 360 pixels

This commit is contained in:
Casey Reas
2011-08-05 18:26:51 +00:00
parent f1c7aabf14
commit 9b7de8d6b7
52 changed files with 295 additions and 302 deletions
@@ -3,8 +3,6 @@
*
* Move the mouse across the screen to move the circle.
* The program constrains the circle to its box.
*
* Updated 27 February 2010 to handle changes in size().
*/
float mx;
@@ -30,7 +30,7 @@ void setup()
background(numChars/2);
// Set a gray value for each key
for(int i=0; i<numChars; i++) {
colors[i] = color(i, i, i);
colors[i] = color(i);
}
}
@@ -6,12 +6,11 @@
float bx;
float by;
int bs = 75;
boolean bover = false;
int boxSize = 75;
boolean overBox = false;
boolean locked = false;
float bdifx = 0.0;
float bdify = 0.0;
float xOffset = 0.0;
float yOffset = 0.0;
void setup()
{
@@ -26,9 +25,9 @@ void draw()
background(0);
// Test if the cursor is over the box
if (mouseX > bx-bs && mouseX < bx+bs &&
mouseY > by-bs && mouseY < by+bs) {
bover = true;
if (mouseX > bx-boxSize && mouseX < bx+boxSize &&
mouseY > by-boxSize && mouseY < by+boxSize) {
overBox = true;
if(!locked) {
stroke(255);
fill(153);
@@ -36,29 +35,29 @@ void draw()
} else {
stroke(153);
fill(153);
bover = false;
overBox = false;
}
// Draw the box
rect(bx, by, bs, bs);
rect(bx, by, boxSize, boxSize);
}
void mousePressed() {
if(bover) {
if(overBox) {
locked = true;
fill(255, 255, 255);
} else {
locked = false;
}
bdifx = mouseX-bx;
bdify = mouseY-by;
xOffset = mouseX-bx;
yOffset = mouseY-by;
}
void mouseDragged() {
if(locked) {
bx = mouseX-bdifx;
by = mouseY-bdify;
bx = mouseX-xOffset;
by = mouseY-yOffset;
}
}
@@ -13,7 +13,7 @@ void setup() {
}
void draw() {
if(mousePressed) {
if (mousePressed) {
stroke(255);
} else {
stroke(0);