nicatronTg icon

Untitled

nicatronTg | PRO | 04/19/12 06:00:07 AM UTC | 0 ⭐ | 220 👁️ | Never ⏰ | []
text |

2.06 KB

|

None

|

0 👍

/

0 👎

int addCircles = 10;
int totalCircles = 10000000;
int circleCount = 0;
float circleDrift = 5;
Circle[] storeCircles = new Circle[totalCircles]; 
 void setup() {
  size(500,500);
  background(255);
  smooth();
  strokeWeight(1);
  fill(150, 50);
  newCircles();        
}
 void draw() {
  background(255);
  for (int i = 0; i < circleCount; i++) {
    storeCircles[i].moveMe();
    storeCircles[i].drawMe();
    storeCircles[i].dontBeAnIdiotAndDriftOffScreenMeAlsoFollowingNamingConventionsForTheWin();
  } 
}
 void mouseReleased() {
  newCircles();        
}
 void newCircles() {
  for (int i = 0; i < addCircles; i++){ 
    Circle c = new Circle();
    if (circleCount < totalCircles) {
      storeCircles[circleCount] = c;
      circleCount += 1;       
    }
  }
}
 class Circle {
   float x, y, moveX, moveY;                                   
  float radius; 
  color linecol, fillcol; 
  float alph; 
   Circle () {                                
    x = random(width);
    y = random(height);
    radius = random(100) + 10; 
    linecol = color(random(255), random(255), random(255));
    fillcol = color(random(255), random(255), random(255));
    alph = random(255);
    moveX = random(circleDrift) - circleDrift/2;
    moveY = random(circleDrift) - circleDrift/2;
  }
   void drawMe() {                               
    noStroke(); 
    fill(fillcol, alph);
    ellipse(x, y, radius*2, radius*2);
    stroke(linecol, 150);
    noFill();
    ellipse(x, y, 10, 10);
  }
   void moveMe() {
    x += moveX;
    y += moveY;
  }
   void dontBeAnIdiotAndDriftOffScreenMeAlsoFollowingNamingConventionsForTheWin()
  {
    if (x >= 500)
    {
      x -= 1;
      moveX = random(circleDrift) - circleDrift/2;
    } else if (x <= 0)
    {
      x += 1;
      moveX = random(circleDrift) - circleDrift/2;
    }
    if (y >= 500)
    {
      y -= 1;
      moveY = random(circleDrift) - circleDrift/2;
    } else if ((y <= 0))
    {
      y += 1;
      moveY = random(circleDrift) - circleDrift/2;
    }
  }
}

Comments