mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
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:
24
js/_checkerboard.js
Normal file
24
js/_checkerboard.js
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user