This commit is contained in:
Casey Reas
2011-09-18 06:31:29 +00:00
parent 76e9248e00
commit 5b0214704c
86 changed files with 95 additions and 178 deletions
+6 -13
View File
@@ -16,10 +16,8 @@ color currentColor;
boolean rectOver = false;
boolean circleOver = false;
void setup()
{
void setup() {
size(640, 360);
smooth();
rectColor = color(0);
rectHighlight = color(51);
circleColor = color(255);
@@ -33,8 +31,7 @@ void setup()
ellipseMode(CENTER);
}
void draw()
{
void draw() {
update(mouseX, mouseY);
background(currentColor);
@@ -55,8 +52,7 @@ void draw()
ellipse(circleX, circleY, circleSize, circleSize);
}
void update(int x, int y)
{
void update(int x, int y) {
if( overCircle(circleX, circleY, circleSize) ) {
circleOver = true;
rectOver = false;
@@ -68,8 +64,7 @@ void update(int x, int y)
}
}
void mousePressed()
{
void mousePressed() {
if(circleOver) {
currentColor = circleColor;
}
@@ -78,8 +73,7 @@ void mousePressed()
}
}
boolean overRect(int x, int y, int width, int height)
{
boolean overRect(int x, int y, int width, int height) {
if (mouseX >= x && mouseX <= x+width &&
mouseY >= y && mouseY <= y+height) {
return true;
@@ -88,8 +82,7 @@ boolean overRect(int x, int y, int width, int height)
}
}
boolean overCircle(int x, int y, int diameter)
{
boolean overCircle(int x, int y, int diameter) {
float disX = x - mouseX;
float disY = y - mouseY;
if(sqrt(sq(disX) + sq(disY)) < diameter/2 ) {