mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
This commit is contained in:
@@ -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 ) {
|
||||
|
||||
Reference in New Issue
Block a user