Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : Visualise Real time long CSV datatype

$
0
0


ok this is a more chaoswise product



  1. //
  2. ArrayList<Ball> balls;
  3. final int ballWidth = 1;
  4. int myAttentionValue=0;
  5. float angle;
  6. //
  7. // ---------------------------------------------------------------
  8. //
  9. void setup()
  10. {
  11.   // init
  12.   size(800, 600);
  13.   frameRate(13);
  14.   // Create an empty ArrayList
  15.   balls = new  ArrayList();
  16.   for (int i=0; i < 122; i++) {
  17.     balls.add(new Ball(mouseX, 300, ballWidth,
  18.     color ( 255, 0, 0)));
  19.   }
  20. } // func
  21. //
  22. //
  23. void draw()
  24. {
  25.   background(255);
  26.   strokeWeight(2);
  27.   for (int i=0; i < myAttentionValue; i++) {
  28.     angle= radians(random(360));
  29.     float radius = random (myAttentionValue) ;
  30.     point (
  31.     300+radius*cos(angle),
  32.     300+radius*sin(angle)
  33.       );
  34.   }
  35.   if (frameCount % 2 == 0 ) {
  36.     myAttentionValue++;
  37.   }
  38.   if (myAttentionValue>=100)
  39.     exit();
  40.   // angle+=7;
  41.   println ("myAttentionValue  "+ myAttentionValue);
  42. } // func
  43. //
  44. // =====================================================================
  45. void mouseReleased() {
  46.   // A new ball object is added to the ArrayList (by default to the end)
  47.   balls.add(new Ball(mouseX, mouseY, ballWidth,
  48.   color (random(0, 255), random(0, 255), random(0, 255))));
  49. }
  50. // =====================================================================
  51. // Simple bouncing ball class
  52. class Ball {
  53.   float x;
  54.   float y;
  55.   color myColor;
  56.   float speed;
  57.   float gravity;
  58.   float w;
  59.   float life = 255;
  60.   Ball(float tempX, float tempY, float tempW, color tempmyColor1) {
  61.     x = tempX;
  62.     y = tempY;
  63.     w = tempW;
  64.     myColor=tempmyColor1;
  65.     speed = 0;
  66.     gravity = 0.1;
  67.   }
  68.   void move() {
  69.     // Add gravity to speed
  70.     speed = speed + gravity;
  71.     // Add speed to y location
  72.     y = y + speed;
  73.     // If ball reaches the bottom
  74.     // Reverse speed
  75.     if (y >= height-19) {
  76.       // Dampening
  77.       speed = speed * -0.8;
  78.       y = height-19;
  79.     }
  80.   }
  81.   boolean finished() {
  82.     // Balls fade out
  83.     life--;
  84.     if (life < 0) {
  85.       return true;
  86.     }
  87.     else {
  88.       return false;
  89.     }
  90.   }
  91.   //
  92.   void display(float i) {
  93.     // Display the ball
  94.     fill(myColor);
  95.     stroke(myColor);
  96.     ellipse(i, y, w, w);
  97.     point(i, y);
  98.   } // method
  99.   //
  100. } // class  
  101. // =====================================================================


Viewing all articles
Browse latest Browse all 1768

Trending Articles