xxxxxxxxxx
let t=0, tch=false,run=true;
function setup() {
createCanvas(44, 44, WEBGL);
pixelDensity(2);
frameRate(8);
}
function draw() {
background(!tch?255:0);
stroke(tch?255:0);
fill(!tch?127+63:127-63)
rotateX(t);
rotateY(t);
box(27);
if(run)t+=0.05;
}
function mousePressed(){
if(mouseX>0 && mouseX<44 && mouseY>0 && mouseY<44) tch=true;
}
function mouseReleased(){
tch=false;
}
function touchStarted(){
if(mouseX>0 && mouseX<44 && mouseY>0 && mouseY<44) tch=true;
}
function touchEnded(){
tch=false;
}
function mouseClicked(){
if(mouseX>0 && mouseX<44 && mouseY>0 && mouseY<44) run=!run;
}