Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int f, elements = 20;
- float[] sz = new float[elements];
- float[] rot = new float[elements];
- int[] col = new int[elements];
- color[] palette = {
- #EFFFCD, #555152, #DCE9BE, #2E2633, #99173C
- };
- float theta, rotOff, scal;
- boolean save;
- void setup() {
- size(500, 500);
- rectMode(CENTER);
- float Sz = width*.75;
- for (int i=0; i<elements; i++) {
- Sz -= random(10, 20);
- sz[i] = Sz ;
- rot[i]= PI/elements*i;
- col[i] = (int) random(0, 5);
- }
- }
- void draw() {
- background(20);
- translate(width/2, height/2);
- for (int i=0; i<elements; i++) {
- pushMatrix();
- rotOff = map(sin(rot[i]+theta), -1, 1, -20, 20);
- scal = map(sin(rot[i]+theta),-1,1,.7,2);
- rotate(radians(rotOff));
- fill(palette[i%5]);
- noStroke();
- rect(0, 0, sz[i]*scal, sz[i]*scal, 20);
- popMatrix();
- }
- theta += 0.0523;
- if (save) {
- if (frameCount%4==0 && frameCount<f+121) saveFrame("image-###.gif");
- }
- }
- void mouseClicked() {
- setup();
- }
- void keyPressed() {
- f = frameCount;
- save = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement