Flags with Rectangles
1) Movement in Squares
Input
x
function drawFlag(ctx)
{
ctx.fillStyle = 'white';
ctx.fillRect(0,0,240,240);
for(let y=0;y<12;y++){
for(let x=0;x<24;x++){
if ((x+y)%2==1){
ctx.fillRect(240*x/24,240*y/12,240/24,240/12);
}
}
}
}
Output
function drawFlag(ctx) { ctx.fillStyle = 'white'; ctx.fillRect(0,0,240,240); for(let y=0;y<12;y++){ for(let x=0;x<24;x++){ if ((x+y)%2==1){ ctx.fillRect(240*x/24,240*y/12,240/24,240/12); } } } }
function drawFlag(ctx) { ctx.fillStyle = 'green'; ctx.fillRect(0,0,150,100); }