From f7100ff9f7e462cc84e9014bd33490f2ae5df5c2 Mon Sep 17 00:00:00 2001 From: npalomba Date: Mon, 1 Apr 2019 21:37:53 +0200 Subject: [PATCH] Added comments, removed unused variables. Signed-off-by: npalomba --- js/_canvas.js | 7 +++++++ js/_checkerboard.js | 15 +++++++++++---- js/_drawLine.js | 3 +++ js/_mouseEvents.js | 7 ++++--- js/_updateCursor.js | 1 + js/_variables.js | 12 ++++++------ 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/js/_canvas.js b/js/_canvas.js index f1bc862..dafb44a 100644 --- a/js/_canvas.js +++ b/js/_canvas.js @@ -1,3 +1,9 @@ +/** Handler class for a single canvas (a single layer) + * + * @param width Canvas width + * @param height Canvas height + * @param canvas HTML canvas element + */ function Canvas(width, height, canvas) { this.canvasSize = [width, height], this.canvas = canvas, @@ -23,6 +29,7 @@ function Canvas(width, height, canvas) { this.canvas.style.left = 64+canvasView.clientWidth/2-(this.canvasSize[0]*zoom/2)+'px'; this.canvas.style.top = 48+canvasView.clientHeight/2-(this.canvasSize[1]*zoom/2)+'px'; }, + // Resizes canvas this.resize = function() { let newWidth = (this.canvas.width * zoom) + 'px'; let newHeight = (this.canvas.height *zoom)+ 'px'; diff --git a/js/_checkerboard.js b/js/_checkerboard.js index 2deaef9..9c4b7dc 100644 --- a/js/_checkerboard.js +++ b/js/_checkerboard.js @@ -1,13 +1,15 @@ +// This script contains all the functions used to manage the checkboard + +// Setting current colour (each square has a different colour var currentColor = firstCheckerBoardColor; +// Saving number of squares filled until now var nSquaresFilled = 0; -/* TODO add check for canvas dimentions (right now negative values can be inserted and a canvas will be generated, it is just - necessary to add a conversion from negative to positive values. - */ - function fillCheckerboard() { + // Getting checkerboard context var context = checkerBoard.context; + // Cycling through the canvas (using it as a matrix) for (var i=0; i