/*
ARTD 252 (Lab 1400)
Xiaoxiang Liu (951032177)
04/27
Titile: The Core of Store Consciousness

I took this concept from Buddhism. Both polluted and purified seeds
are stored in this core consciousness. Because of the srore 
consciousness in a "mysterious mixture of purity and defilement, 
good and evil", "that the transformation of consciousness can take 
place and enlightenment can be experienced."

I was thinking about creating an illusionary dynamic core 
implicating the store consciousness. I used dark blue and green to 
describe its intangibility abd I used bright orange to indicate the
"hope." I was also thinking about designing it in the way when the 
mouse clicks on the circle, there would be a random
curve produced; and also there were advices on discussion board 
suggesting me to make it more interactive. However, because of my 
limited skill, I couldn't put them into practice.
*/


Individual[] community;
// Creating a array for holding 7500 seeds.
int communitySize = 7500;
// Inputing the number 7500 to "communitySize."
Random rnd = new Random();
// Making "Random rnd" as a datatype of Random.
 
void setup() { 
  size(600,600,P2D); 
// Creating 600*600 window.
// Using Processing 2D renter to increase the speed.
  background(0);
// No background 

    community = new Individual[communitySize]; 
// Connceting "communitySize" to Individual[], so Individual[] can hold 7500 items.
  for (int i=0; i < communitySize; i++) { 
// Roop code, unlimited running times. Program won't stop by itself.
    community[i] = new Individual();
// Making "community[i] as a datetyple o fIndividual.    
  } 
} 
 
void draw() { 
// Create a rectanle.
  noStroke(); 
// Without outlines.
  fill(10,30); 
// A little bit gray with opacity as 30 will make the track of seeds visible.
  rect(0,0,width,height); 
// As big as the window.
   
  for (int i=0; i < communitySize; i++) {     
    community[i].move(); 
    community[i].draw(); 
// Roop code, so the program will run the bottom move() and draw() again and again.
  }     
 
} 
 
class Individual { 
  float angle; 
  float shift; 
  float shiftSpeed; 
  float angularSpeed; // angular speed 
  color c; 
  float widthLimit;
// Creating a group of variable identifying the properties of the seed.
   
  Individual() { 
    angle = random(0, 360);
// Making the seed can move around a circle track. 
    shift = 0; 
// Setting the starting point of the seed.
    shiftSpeed = random(-0.01, 0.01); 
// Deciding the moving speed of seeds along radius, randomly from -0.01 to 0.01
    widthLimit = (float)rnd.nextGaussian() * 45; 
// Defining the width of the circle track.                
    angularSpeed = random(PI/24, PI/6); 
// Defining the moving speed on the circle track.
    float tmp = random(0,1);
// Creating a random variable for choosing the color. 
    if (tmp < 0.3) { 
      c = #202c60; 
// The color will be blue by the chance of 30%.
    } else if (tmp < 0.9) { 
      c = #0a3006; 
// The color will be green by the chance of 60%.
    } else { 
      c = color(134,77,9); 
// The color will be orange by the chance of 10%.
    } 
  } 
     
  void move() { 
// defining the movement of seeds.
    float tmp = random(0,1);  
// Creating a random variable for deciding the moving direction of seeds. 
    if (tmp< 0.5) {
    angle += angularSpeed;
// Seed will move toward clockwise direction by the chance of 50%. 
    } else {
    angle -= angularSpeed;
// Seed will move levorotary direction by the chance of 50%.
    }
    if (angle > 360) { 
      angle -= 360; 
    }
// Making the seed can move round again after finishing a lap.
    shift += shiftSpeed; 
    shiftSpeed += random( -0.05, 0.05 ); 
// Making the seed can slightly over the boundary of the circle track.
    if (shift > widthLimit) { 
      shiftSpeed = Math.abs(shiftSpeed) * -0.5; 
// When the seed is outside the track boundary, it will move toward inside.      
    } 
    else if (shift < -widthLimit) { 
      shiftSpeed = Math.abs(shiftSpeed) * 0.5; 
// When the seed is inside the track boundary, it will move toward outside.
    } 
     
  } 
   
  void draw() { 
// Creating the image of each seed.
    noStroke(); 
// Without outlines
    fill(c, 127);
// Random color with opacity of 127. 
    float baseRadius = width / 5;
// Seeds are moving around a circle of radius 5.
    float x = cos(angle) * (baseRadius + shift) + (width / 2); 
    float y = sin(angle) * (baseRadius + shift) + (height / 2);
// Difining the location of the track circle. 
    ellipse(x, y, 4, 4); 
// Drawing seeds as they are 4,4 balls
  } 
     
}