Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ArrayList thingies = new ArrayList();
- float grid, sz, theta;
- int flip = -1;
- int stepx = 20;
- int stepy = stepx/5*3;
- int column, row;
- color bg = #555152 ;
- color f1 = #2E2633 ;
- color f2 = #99173C ;
- void setup() {
- size(500, 300);
- background(bg);
- stroke(bg);
- column = width/stepx;
- row = height/stepy;
- sz = column -2;
- rectMode(CENTER);
- for (int y=0; y<height; y+=row) {
- flip *= -1;
- for (int x=0; x<width;x+=column) {
- Thingie thingie = new Thingie(x, y, flip, theta);
- thingies.add(thingie);
- flip *= -1;
- theta += TWO_PI/stepx;
- }
- }
- }
- void draw() {
- background(bg);
- for (int i=0; i<thingies.size();i++) {
- Thingie thing = (Thingie) thingies.get(i);
- thing.display();
- }
- if (frameCount % 4 == 0 && frameCount < 121) saveFrame("image-####.gif");
- }
- class Thingie {
- float edge, theta, theta2, x, y;
- int flip;
- Thingie(float _x, float _y, int _flip, float _theta) {
- x = _x;
- y = _y;
- flip = _flip;
- theta = _theta;
- theta2 = _theta;
- }
- void display() {
- fill(#ECE3B7);
- noStroke();
- //stroke(bg);
- edge = map(sin(theta), -1, 1, 0, .5*sz);
- if (flip == 1) {
- fill(f1);
- }
- else {
- fill(f2);
- }
- pushMatrix();
- translate(x+column/2, y+column/2);
- rotate(theta2);
- rect(0, 0, sz, sz, edge);
- popMatrix();
- theta -= 0.0523;
- theta2 -= (0.0523);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement