Added _checkerboard.js for transparency checkerboard management. Implemented generation of checkerboard (still need to test it properly, for example with weird height/width values).

Signed-off-by: npalomba <nicola.palomba@studenti.galileilivorno.gov.it>
This commit is contained in:
npalomba
2019-03-31 13:28:46 +02:00
parent 7b26ebb5fd
commit 15e6d7b08a
8 changed files with 62 additions and 8 deletions

24
js/_checkerboard.js Normal file
View File

@@ -0,0 +1,24 @@
var currentColor = firstCheckerBoardColor;
function fillCheckerboard() {
for (var i=0; i<canvasSize[0] / checkerBoardSquareSize; i++) {
for (var j=0; j<canvasSize[1] / checkerBoardSquareSize; j++) {
context.fillStyle = currentColor;
context.fillRect(i * checkerBoardSquareSize, j * checkerBoardSquareSize, checkerBoardSquareSize, checkerBoardSquareSize);
changeCheckerboardColor(false);
}
changeCheckerboardColor(false);
}
}
function changeCheckerboardColor(rowEndReached) {
if (!rowEndReached) {
if (currentColor == firstCheckerBoardColor) {
currentColor = secondCheckerBoardColor;
} else if (currentColor == secondCheckerBoardColor) {
currentColor = firstCheckerBoardColor;
}
}
}