xxxxxxxxxx
ArrayList<Circle> poop = new ArrayList();
PImage img;
void setup() {
img = loadImage("perro2.jpg");
// size(img.width, img.height);
size(1024, 768);
color ck = get(width/2, height/2);
ck = color(ck, 80);
Circle c = new Circle(1, 1, width, ck , 0,0,0,0);
poop.add(c);
}
int k=0;
char typ = 'P';//<---------------------------P or not to P
void draw() {
// background(img);
if (k<1) image(img, 0, 0);
for (int i=0; i<poop.size (); i++) {
Circle C = poop.get(i);
C.show();
}
for (int i=0; i<poop.size (); i++) {
Circle C = poop.get(i);
if ( ( ((mouseX>= C.x)&&(mouseX<= C.x+C.r)) && ((mouseY>= C.y)&&(mouseY<= C.y+C.r)) ) && (press) ) {
poop.remove(i);
for (int kx=0; kx<2; kx++) {
for (int ky=0; ky<2; ky++) {
color c = img.get(int(C.x + C.r * kx/2 ), int(C.y + C.r * ky/2 ));
if ( typ == 'P'){
Circle C1 = new Circle(int(C.x + C.r * kx/2 ), int(C.y + C.r * ky/2 ), C.r/2, c, 0,0,0,0);
poop.add(C1);
} else {
Circle C1 = new Circle(int(C.x + C.r * kx/2 ), int(C.y + C.r * ky/2 ), C.r/2, c, int(random(-C.r, C.r)*0.1), int(random(-C.r, C.r)*0.1),int(random(-C.r, C.r)*0.1),int(random(-C.r, C.r)*0.1));
poop.add(C1);
}
press =false;
}
}
}
}
}
boolean press=false;
void mouseDragged() {
press = true;
k++;
// if ((mouseButton == RIGHT)) {
//saveFrame("perro-######.jpg");
// }
}
class Circle {
float x, y, r, r1, r2, r3, r4;
color c;
Circle(float x, float y, float r, color c, float r1, float r2, float r3, float r4 ) {
this.x = x;
this.y = y;
this.r = r;
this.r1 = r1;
this.r2 = r2;
this.r3 = r3;
this.r4 = r4;
this.c = c;
}
void show() {
noStroke();
fill(c);
quad(x +r1, y-r1, x+r+r2, y+r2, x+r-r3, y+r-r3, x-r4, y+r+r4);
}
}
void mousePressed() {
if (mousePressed && (mouseButton == RIGHT)) {
saveFrame("perro-######.jpg");
}
}
//