Colorbox cbox; int sdiv; //--------------- void setup(){ size(300, 300, P3D); sdiv = 3; cbox = new Colorbox(120, sdiv); } //--------------- void draw(){ background(0); translate(width/2, height/2, 0); float rotx = -0.20*PI + 0.2*HALF_PI*(1-mouseY*2.0/width); float roty = -0.25*PI + 0.2*HALF_PI*(1-mouseX*2.0/width); rotateX(rotx); rotateZ(PI); rotateY(roty); cbox.show(); } //--------------- void mousePressed(){ sdiv = (sdiv-2+1)%4+2; cbox = new Colorbox(120, sdiv); } //------------------------------------------ class Colorbox { int subdiv, sze; int separation; float boxsze; PImage[] tex; //--------------- Colorbox(int sze_param, int subdiv_param) { sze = sze_param; subdiv = subdiv_param; separation = 5; boxsze = (sze-separation*(subdiv-1))/subdiv; } //--------------- void show() { noStroke(); translate(-sze/2+boxsze/2,-sze/2+boxsze/2,-sze/2+boxsze/2); for (int x=0 ; x