xxxxxxxxxx
var fillStyle=0;
var alph=0;
var inc =0;
var xv=10;
function setup() {
createCanvas(windowWidth, windowHeight);
background(100);
smooth();
frameRate(60);
}
function draw() {
background(200);
checkerboard(-60,-60);
push();
translate(width/2,height/2);
rotate(TWO_PI/360*inc);
checkerboard(-width/2-80,-height/2-80);
pop();
inc+=1;
}
function checkerboard(xx,yy){
var xv=20;//map(mouseX,0,width,10,20);
var yv=15;//map(mouseY,0,height,10,20);
for(var i = xx;i<width+35;i+=xv){ //Set up a nested loop for the rows & columns
for(var j =yy;j<height+35;j+=xv){
fill(fillStyle,alph); //Set the fill color to be the color stored in fillStyle
rect(i,j,xv,xv); //Draw the square
if(fillStyle==0){ //Switch the fill color variable after drawing each square
fillStyle=255;
alph=0;
}
else{
fillStyle=0;
alph=255;}
}
if((i+j)%2==0 && fillStyle==0){
fillStyle=255;
alph=0;}
else if((i+j)%2==0 && fillStyle==255){
fillStyle=0;
alph=255;}
}
}