Main Sketch
Marker shawn;
Marker fred;
Marker currentMarker;
void setup() {
shawn = new Marker(color(0,255,0), 5, 100, "Flash");
fred = new Marker(color(0,0,255), 70, 100000, "Cartoon");
currentMarker = shawn;
}
void draw() {
currentMarker.leak(mouseX,mouseY);
}
void mousePressed() {
currentMarker.draw(mouseX,mouseY);
}
void mouseDragged() {
currentMarker.draw(mouseX,mouseY);
}
void keyPressed() {
if (key == '1') {
// Shawn
currentMarker = shawn;
}
else {
// Fred
currentMarker = fred;
}
}
Marker Class
class Marker {
color myColor;
int myRadius;
int amountOfInk;
String brand;
public Marker(color _myColor, int _myRadius, int _amountOfInk, String _brand) {
myColor = _myColor;
myRadius = _myRadius;
amountOfInk = _amountOfInk;
brand = _brand;
}
void draw(int x, int y) {
fill(myColor);
if (amountOfInk > 0) {
ellipse(x,y,myRadius,myRadius);
amountOfInk--;
}
}
void leak(int x, int y) {
fill(myColor);
if (amountOfInk > 0) {
ellipse(x+int(random(-10,10)),y+int(random(-10,10)),random(0,myRadius),random(0,myRadius));
amountOfInk--;
}
}
}