/* UPF :: IUA-IDEC Màster d'Arts Digitals joan soler-adillon (www.joan.cat) Clica el mouse para hacer que el globo crezca hasta pinchar */ int sz = 20; //tamaño del globo: inicialmente 20 int crecimiento = 1; //variable de crecimiento del globo int tamanoPincho = 50; //tamaño del pincho void setup(){ size(300,300); fill(255,255,127); smooth(); stroke(255,127,127); } void draw(){ background(0); //dibujamos el pincho: stroke(255,127,127); line(0,height/2,tamanoPincho,height/2); //y segundo, hacemos que el STROKE dependa de eje vertical del mouse if(mousePressed){ //si está apretado el botón del mouse sz = sz + crecimiento; //size va a crecer según la variable "crecimiento" } /*antes de dibujar el globo, hay que comprobar si toca o on el pincho sabemos que el globo toca el pincho si la mitad de su diámetro es menor a medio WIDTH menos el tamaño del pincho */ if(sz/2 > (width/2)-tamanoPincho){ //como ha tocado el pincho, dibujamos un recuadro rojo: fill(255,0,0); rect(0,0,width,height); } else { //como no lo toca, lo dibujamos //dibujamos el globo: //sin stroke: noStroke(); ellipse(width/2,height/2,sz,sz); println(sz); } }