Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Square[] squares;
- int elem, unit;
- color f;
- void setup() {
- size(500, 500);
- background(255);
- int counter=0;
- int i=0;
- float div = 20;
- float theta=0;
- unit = int(width/div);
- elem = int(sq(div-2));
- squares = new Square[elem];
- for (int y = unit; y<height-unit; y +=unit) {
- for (int x = unit; x<width-unit; x +=unit) {
- squares[i] = new Square(float(x), float(y), theta, random(3));
- i++;
- theta += TAU/elem;
- }
- }
- }
- void draw() {
- background(#202020);
- for (int i=0; i<squares.length; i++) {
- squares[i].display();
- }
- if (frameCount % 3 == 0 & frameCount<121) saveFrame("image-####.gif");
- }
- class Square {
- float x, y, w, h, r, theta;
- Square(float _x, float _y, float _theta, float _r) {
- x = _x;
- y = _y;
- h = unit;
- theta = _theta;
- r = _r;
- }
- void display() {
- w = map(sin(theta), -1, 1, 5, unit-5);
- if (r<2.5) {
- stroke(#777777);
- noFill();
- }
- else {
- fill(#FCD300);
- noStroke();
- }
- //noFill();
- rect(x, y, w, w,0);
- theta -= 0.0523;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement