Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- color[] col = {#2537b5, #ff3804}; // the theme colors
- int num = 11; //number of circles
- int frms = 200; // number of frames for animation
- float angle, destx, desty, dif;
- float[] px = new float[num];
- float[] py = new float[num];
- float[] psz = new float[num];
- float scal = 1.2;
- void setup() {
- size(350, 350, P2D);
- background(255);
- destx = width/2; // horizontal center of the image
- desty = height/2; // vertical center of the image
- initCircles();
- }
- void draw() {
- background(255);
- drawCircles();
- //if (frameCount%frms==0) initCircles();
- if (frameCount<=frms) saveFrame("image-###.gif");
- }
- void initCircles() {
- float sz = width*.75; //start size for the left series of circles
- float incr = sz/num*1.7; // value the circles decrease each step
- float sz2 = sz-incr/2; //start size for the right series of circles
- dif = incr/4; //value added to x to get the center for the right series of circles
- float sw = dif*.45; //strokeWeight
- for (int i=0; i<num; i++) {
- float x = destx + sin(angle)*width*scal;
- float y = desty + cos(angle)*height*scal;
- px[i] = x;
- py[i] = y;
- angle -= TWO_PI/num;
- if (i%2==0) {
- sz -= incr;
- psz[i] = sz;
- } else {
- sz2 -= incr;
- psz[i] = sz2;
- }
- }
- strokeWeight(sw);
- }
- void drawCircles() {
- for (int i=0; i<num; i++) {
- py[i] = lerp(py[i], desty, 0.05);
- if (i%2==0) {
- fill(col[0]);
- px[i] = lerp(px[i], destx, 0.05);
- ellipse(px[i], py[i], psz[i], psz[i]);
- } else {
- fill(col[1]);
- px[i] = lerp(px[i], destx+dif, 0.1);
- ellipse(px[i], py[i], psz[i], psz[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement