Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int columns = 20;
- float col_sz, theta, theta2;
- Ball[][] ball = new Ball[columns][columns];
- color[] palette = {#BD1550, #E97F02, #F8CA00, #8A9B0F};
- color bg = #490A3D;
- void setup() {
- frameRate(20);
- size(400, 400);
- background(bg);
- noStroke();
- col_sz = width/columns;
- theta = PI/2;
- float x, y;
- for (int j=0; j<columns; j++) {
- int col = j%4;
- //theta = noise(j*4)*TAU;
- theta = map(sin(theta2),-1,1,0,TAU);
- theta2 += TAU/12;
- for (int i=0; i<columns; i++) {
- x = col_sz/2+i*col_sz;
- y = col_sz/2+j*col_sz;
- ball[i][j] = new Ball(x, y, theta, col);
- theta -= TAU/columns;
- }
- }
- }
- void draw() {
- background(bg);
- for (int j=0; j<columns; j++) {
- for (int i=0; i<columns; i++) {
- ball[i][j].display();
- }
- }
- if (frameCount % 2 == 0 && frameCount<61) saveFrame("image-####.gif");
- }
- class Ball {
- float x, y, theta, sz;
- int col;
- Ball(float _x, float _y, float _theta, int _col) {
- x = _x;
- y = _y;
- theta = _theta;
- col = _col;
- }
- void display() {
- fill(palette[col]);
- sz = map(sin(theta), -1, 1, 0, col_sz*1.0);
- ellipse(x, y, sz, sz);
- theta += (2*.0523);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement