// by Albert Serra int i; int cx1,cx2,cx3,cx4,cx5,cx6=0; int cy1,cy2,cy3,cy4,cy5,cy6=0; int vx1,vx2,vx3,vx4,vx5,vx6=0; int vy1,vy2,vy3,vy4,vy5,vy6=0; int rx1,rx2,rx3,rx4=10; int ry1,ry2,ry3,ry4=10; int rx5,ry5=1; //---------------------------------------------------------- void setup() { size(400,400); background (0); pinta1(); } //---------------------------------------------------------- void draw() { background(0); if (i<=30) { pinta1(); i++; } else { pinta2(); } cercle1(); cercle2(); cercle3(); cercle4(); cercle5(); } //---------------------------------------------------------- void pinta1(){ fill (255,223,0); ellipse (0,0,100,100); stroke (255,223,0); // Canvia el color d'una línea); strokeWeight (10); line (50,0,370,0); line (45,15,380,100); line (40,30,390,250); line (25,45,375,400); line (10,50,150, 390); line (0,50,0, 250); } void pinta2(){ if(mousePressed) { fill (255); stroke(255); } else { fill (random(245,255),0,0); stroke (random(150,255),0,0); } strokeWeight(10); ellipse (0,0,100,100); // Canvia el color d'una línea); line (50,0,370,0); line (45,15,380,100); line (40,30,390,250); line (25,45,375,400); line (10,50,150, 390); line (0,50,0, 250); } void cercle1() { stroke(255,random(0,223),0); strokeWeight(5); fill (255,223,0); ellipse(cx1,cy1,rx1,ry1); rx1= (int) (random (2,3) + rx1); ry1= (int) (random (2,3) + ry1) ; if (cx1==width) { cx1=0; cy1=0; rx1=1; ry1=1; } else { vx1=2; cx1= cx1 + vx1; } } void cercle2() { stroke(255,223,0); strokeWeight(0); fill (255,223,0); ellipse(cx2,cy2,rx2,ry2); rx2= (int) (random (1,2) + rx2); ry2= (int) (random (1,2) + ry2) ; if (cx2==width+30) { cx2=0; cy2=0; rx2=10; ry2=10; } else { vx2=2; vy2= vx2*1/2; cx2= cx2 + vx2; cy2=cy2 + vy2; } } void cercle3() { stroke(255,223,0); strokeWeight(0); fill (255,223,0); ellipse(cx3,cy3,rx3,ry3); if (cx3==width+30) { cx3=0; cy3=0; rx3=40; ry3=40; } else { vx3=2; vy3= vx3*2; cx3= cx3 + vx3; cy3=cy3 + vy3; } } void cercle4() { stroke(223,random(0,255),random(0,255)); strokeWeight(0); fill (223,random(0,255),random(0,255)); ellipse(cx4,cy4,rx4,ry4); rx4= (int) (random (1,2) + rx4); ry4= (int) (random (1,2) + ry4) ; if (cx4==width+30) { cx4=0; cy4=0; rx4=10; ry4=10; } else { vx4=5; vy4= vx4*2; cx4= cx4 + vx4; cy4=cy4 + vy4; } } void cercle5() { stroke(random(0,255),223,random(0,125)); strokeWeight(0); fill (random(0,255),223,random(0,125)); ellipse(cx5,cy5,rx5,ry5); rx5= (int) (random (1,2) + rx5); ry5= (int) (random (1,2) + ry5) ; if (cx5==width+30) { cx5=0; cy5=0; rx5=(int)random(1,2); ry5=rx5; } else { vx5=1; vy5=vx5; cx5= cx5 + vx5; cy5=cy5 + vy5; } }