int stageW = 1440;
int stageH = 1440;
color bgClr = #242424;
// ********************************************************************************************************************
int cols = 35;
int rows = 35;
int total = cols * rows;
float zDepth;
int rSize = 100;
// ********************************************************************************************************************
// gray light gray red purple red
color[][] clr1 = { {102,102,102}, {153,153,153}, {236,31,39}, {102,47,144}, {236,31,39} };
int clr1Len = clr1.length;
int clr1Num = total;
int clr1Cnt = -1;
int clr1Blk = floor(clr1Num/clr1Len);
color[] clr1A = new color[clr1Num];
// ********************************************************************************************************************
void settings() {
size(stageW,stageH,P3D);
}
void setup() {
background(bgClr);
// set colors
for (int i = 0; i < clr1Num; ++i) {
if( i%clr1Blk==0 ) clr1Cnt = (clr1Cnt+1)%clr1Len;
color _c1 = color(clr1[(clr1Cnt)][0], clr1[(clr1Cnt)][1], clr1[(clr1Cnt)][2]);
color _c2 = color(clr1[(clr1Cnt+1)%clr1Len][0], clr1[(clr1Cnt+1)%clr1Len][1], clr1[(clr1Cnt+1)%clr1Len][2]);
clr1A[i] = lerpColor( _c1, _c2, map(i, (clr1Cnt*clr1Blk), (((clr1Cnt+1))*clr1Blk), 0.0, 1.0) );
}
}
void draw() {
background(bgClr);
strokeWeight(0);
noStroke();
lights();
float pers = map(sin(radians(frameCount*0.5)), -1,1, 1.75, 7.0);
perspective(PI/pers, (float)(width*2)/(height*2), 0.1, 1000000);
translate((width/2), (height/2));
int frameColumns = cols;
int frameRows = rows;
for(int level=0; level<=ceil(cols/2); level++) {
int frameWidth = frameColumns*rSize;
int frameHeight = frameRows*rSize;
zDepth = map(sin(radians(frameCount+level*30)), -1,1, -10, -1) * rSize;
for (int c=0; c<frameColumns; c++) {
for (int r=0; r<frameRows; r++) {
if (c==0 || c==frameColumns-1 || r==0 || r==frameRows-1) {
int x = c*rSize + rSize/2;
int y = r*rSize + rSize/2;
fill( clr1A[ ((level*100)+(frameCount*10))%clr1Num ], 245 );
float dSize = map(sin(radians(frameCount+level*10)), -1,1, rSize/2, rSize*20);
pushMatrix();
translate(x-frameWidth/2, y-frameHeight/2, zDepth);
box(rSize/2, rSize/2, dSize);
popMatrix();
}
}
}
frameColumns-=2;
frameRows-=2;
}
surface.setTitle( int(frameRate) + " FPS " );
}
Comments