// TiTi - 17 Aug 2021 int phase=0; float time=0, hue_step=256/float(14); void setup() { size(800, 800); strokeWeight(10); frameRate(60); noFill(); strokeCap(ROUND); colorMode(HSB); } void draw() { background(176); translate(width/2, height/2); noFill(); stroke(160); ellipse(0, 0, 650, 650); if (phase>=14) rotate(TAU/3*ease((time+phase-14)*.5)-TAU/3); else rotate(TAU/3*phase); pushMatrix(); fill(190); noStroke(); for (int i=0; i<3; i++) { center_part(i); rotate(TAU/3); } popMatrix(); noFill(); stroke(176); for (int i=2; i>=0; i--) { pushMatrix(); translate(0, -150); if (phase<14 && i==0) rotate(-ease(time)*TAU/6); rotate(PI-PI/6); for (int j=0; j<6; j++) { if (!(j==0&&i==1 || j==5&&i!=0)) { pushMatrix(); int offset=min(phase, 14)*9; if (i==0) offset++; if (j==5&&i==0) fill(176); else fill(((j+i*5+offset)*hue_step)%256, 70, 220); peas(); popMatrix(); } rotate(-TAU/6); } popMatrix(); rotate(TAU/3); } time(); //if(frameCount<=50*16) saveFrame("frames2/####.png"); } void center_part(int a) { //ellipse(0, -150, 280, 280); pushMatrix(); translate(0, -150); if (phase<14 && a==2) rotate(-ease(time)*TAU/6); beginShape(); for (int i=0; i<6; i++) { //offset of circle float x_offset=cos(TAU/6*i)*280; float y_offset=sin(TAU/6*i)*280; for (int j=5; j>=-6; j--) { //each "i" part takes 1/6 of the hexagon float x = x_offset+cos(PI+float(j)/5*PI/12+PI/3*i)*190; float y = y_offset+sin(PI+float(j)/5*PI/12+PI/3*i)*190; vertex(x,y); //point(x,y); } } endShape(CLOSE); popMatrix(); } void peas() { beginShape(); float frac=PI/30; for (int i=-5; i<=5; i++) vertex(cos(-HALF_PI+i*frac)*150, sin(-HALF_PI+i*frac)*150); for (int i=-4; i<=4; i++) vertex(cos(HALF_PI+i*frac)*150, sin(HALF_PI+i*frac)*150-260); endShape(CLOSE); //ellipse(0, -120, 145, 40); } void time() { time += float(1)/50; if (time>=1) { time-=1; phase++; if (phase>=16) phase-=16; } } float ease(float x) { if (x<.5) return pow(x, 3)*4; return pow(x-1, 3)*4+1; }