/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.Rh4$7SZ3FNZ/rev.712
*
* authors:
*
* mateodd
*
*
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
// This sketch builds on a prior work, "Untitled Sketch", created by [unnamed author]
// http://sketchpad.cc/sp/pad/view/ro.fMkhbrIPT2x/rev.62
// Pressing Control-R will render this sketch.
int count = 40;
int max = 40;
in min = 20;
float[][] c = new float[count][5];
void setup() { // this is run once.
// set the background color
background(100);
// canvas size (Integers only, please.)
size(300, 300);
// smooth edges
smooth();
// limit the number of frames per second
frameRate(10);
for(int i = 0 ; i < count;i++)
{
c[i][0] = random(width);
c[i][1] = random(height);
c[i][2] = random(min,max);
c[i][3] = random(-1,1);
c[i][4] = random(-1,1);
}
}
void draw() { // this is run repeatedly.
background(100);
for(int i = 0 ; i < count;i++)
{
rad = c[i][2];
x = c[i][0];
y = c[i][1];
noStroke();
fill(255,180,0,100);
if( dist (x,y,mouseX,mouseY)<rad/2 )
{
fill(255,180,255,100);
}
ellipse(x,y,rad,rad);
for(int j = i; j < count;j++)
{
if(dist(x,y,c[j][0],c[j][1])<60)
{
stroke();
fill(255,0,255);
line(x,y,c[j][0],c[j][1]);
}
}
noStroke();
fill(0)
ellipse(x,y,3,3);
c[i][0]+=c[i][3];
c[i][1]+=c[i][4];
diam = rad/2;
if( c[i][0] < -diam ){ c[i][0] = width+diam; }
if( c[i][0] > width+diam ){ c[i][0] = -diam; }
if( c[i][1] < 0-diam ){ c[i][1] = height+diam; }
if( c[i][1] > height+diam){ c[i][1] = -diam; }
}
if(mousePressed)
{
fill(250);
//text("Es demasiado bello pequeña :)",mouseX,mouseY);
}
}