ok this is a more chaoswise product
- //
- ArrayList<Ball> balls;
- final int ballWidth = 1;
- int myAttentionValue=0;
- float angle;
- //
- // ---------------------------------------------------------------
- //
- void setup()
- {
- // init
- size(800, 600);
- frameRate(13);
- // Create an empty ArrayList
- balls = new ArrayList();
- for (int i=0; i < 122; i++) {
- balls.add(new Ball(mouseX, 300, ballWidth,
- color ( 255, 0, 0)));
- }
- } // func
- //
- //
- void draw()
- {
- background(255);
- strokeWeight(2);
- for (int i=0; i < myAttentionValue; i++) {
- angle= radians(random(360));
- float radius = random (myAttentionValue) ;
- point (
- 300+radius*cos(angle),
- 300+radius*sin(angle)
- );
- }
- if (frameCount % 2 == 0 ) {
- myAttentionValue++;
- }
- if (myAttentionValue>=100)
- exit();
- // angle+=7;
- println ("myAttentionValue "+ myAttentionValue);
- } // func
- //
- // =====================================================================
- void mouseReleased() {
- // A new ball object is added to the ArrayList (by default to the end)
- balls.add(new Ball(mouseX, mouseY, ballWidth,
- color (random(0, 255), random(0, 255), random(0, 255))));
- }
- // =====================================================================
- // Simple bouncing ball class
- class Ball {
- float x;
- float y;
- color myColor;
- float speed;
- float gravity;
- float w;
- float life = 255;
- Ball(float tempX, float tempY, float tempW, color tempmyColor1) {
- x = tempX;
- y = tempY;
- w = tempW;
- myColor=tempmyColor1;
- speed = 0;
- gravity = 0.1;
- }
- void move() {
- // Add gravity to speed
- speed = speed + gravity;
- // Add speed to y location
- y = y + speed;
- // If ball reaches the bottom
- // Reverse speed
- if (y >= height-19) {
- // Dampening
- speed = speed * -0.8;
- y = height-19;
- }
- }
- boolean finished() {
- // Balls fade out
- life--;
- if (life < 0) {
- return true;
- }
- else {
- return false;
- }
- }
- //
- void display(float i) {
- // Display the ball
- fill(myColor);
- stroke(myColor);
- ellipse(i, y, w, w);
- point(i, y);
- } // method
- //
- } // class
- // =====================================================================