//TV Dinner Dance object Dial
// (button on the TV)
//11/25
// art and code by Marguerite Mooradian
class Dial {
// Location and size
float x;
float y;
float r;
// An AudioPlayer object is used to store the sound.
AudioSnippet dingdong;
// Create the button/dial/thingy
Dial (float x_, float y_, float r_, String filename) {
x = x_;
y = y_;
r = r_;
// load "marilynmanson'sdulcettones.mp3 etc." into a new AudioPlayer
dingdong = minim.loadSnippet(filename);
}
// oh now we're jamming
void ring() {
if (!dingdong.isPlaying()) {
// The ring() function plays the sound, as long as it is not already playing.
// rewind() ensures the sound starts from the beginning.
dingdong.rewind();
dingdong.play();
}
}
// point inside the dial (used for mouse rollover, etc.)
boolean contains(float mx, float my) {
if (dist(mx,my,x,y) < r) {
return true;
} else {
return false;
}
}
// Show the dial. Change the color shape whatever floats your integer... ehhehe yikes
void display(float mx, float my) {
if (contains(mx,my)) {
fill(255,0,0,223);
strokeWeight(11);
stroke(255,255,0,73);
} else {
fill(208,204,156,123);
strokeWeight(2);
stroke(255,0,0,153);
}
ellipse(x,y,r,r);
}
void close() {
// The dial has a close() function to close the AudioPlayer object.
dingdong.close();
}
}