mirror of
https://github.com/processing/processing4.git
synced 2026-01-29 19:31:16 +01:00
new Table example
This commit is contained in:
40
java/examples/Topics/Advanced Data/LoadSaveTable/Bubble.pde
Normal file
40
java/examples/Topics/Advanced Data/LoadSaveTable/Bubble.pde
Normal file
@@ -0,0 +1,40 @@
|
||||
// A Bubble class
|
||||
|
||||
class Bubble {
|
||||
float x,y;
|
||||
float diameter;
|
||||
String name;
|
||||
|
||||
boolean over = false;
|
||||
|
||||
// Create the Bubble
|
||||
Bubble(float x_, float y_, float diameter_, String s) {
|
||||
x = x_;
|
||||
y = y_;
|
||||
diameter = diameter_;
|
||||
name = s;
|
||||
}
|
||||
|
||||
// CHecking if mouse is over the Bubble
|
||||
void rollover(float px, float py) {
|
||||
float d = dist(px,py,x,y);
|
||||
if (d < diameter/2) {
|
||||
over = true;
|
||||
} else {
|
||||
over = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Display the Bubble
|
||||
void display() {
|
||||
stroke(0);
|
||||
strokeWeight(2);
|
||||
noFill();
|
||||
ellipse(x,y,diameter,diameter);
|
||||
if (over) {
|
||||
fill(0);
|
||||
textAlign(CENTER);
|
||||
text(name,x,y+diameter/2+20);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user