Skip to content

Commit

Permalink
Finished linting brainsprite.js. Also switche no-unused-vars to a war…
Browse files Browse the repository at this point in the history
…ning, because I don't seem to manage to declare brainsprite as a global.
  • Loading branch information
pbellec committed Feb 17, 2019
1 parent 993a571 commit 5e33f1c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ module.exports = {
'extends': 'standard',
'globals': {
'Atomics': 'readonly',
'SharedArrayBuffer': 'readonly'
'SharedArrayBuffer': 'readonly',
'brainsprite': 'readonly'
},
'parserOptions': {
'ecmaVersion': 2018
},
'rules': {
'no-unused-vars': ['warn', { 'vars': 'local', 'args': 'after-used',
'ignoreRestSiblings': false }]
}
}
20 changes: 9 additions & 11 deletions brainsprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ function initColorMap (colorMap) {
return colorMap
}

/* exported brainsprite */
function brainsprite (params) {
var brainsprite = function (params) {
// Create and activate a brainsprite viewer object
//
// Parameters
Expand Down Expand Up @@ -497,8 +496,8 @@ function brainsprite (params) {
coord = 'y = ' + Math.round(brain.coordinatesSlice.Y)
coordWidth = brain.context.measureText(coord).width
brain.context.fillText(coord, brain.widthCanvas.X +
(brain.widthCanvas.Y / 2) - coordWidth / 2,
Math.round(brain.canvas.height - (brain.sizeFontPixels / 2)))
(brain.widthCanvas.Y / 2) - coordWidth / 2,
Math.round(brain.canvas.height - (brain.sizeFontPixels / 2)))
}
break

Expand Down Expand Up @@ -528,17 +527,16 @@ function brainsprite (params) {
brain.context.drawImage(brain.planes.canvasZ,
0, 0, brain.nbSlice.X, brain.nbSlice.Y, brain.widthCanvas.X +
brain.widthCanvas.Y, (brain.heightCanvas.max -
brain.heightCanvas.Z) / 2, brain.widthCanvas.Z,
brain.heightCanvas.Z)
brain.heightCanvas.Z) / 2, brain.widthCanvas.Z, brain.heightCanvas.Z)

// Add Z coordinates on the slice
if (brain.flagCoordinates) {
coord = 'z = ' + Math.round(brain.coordinatesSlice.Z)
coordWidth = brain.context.measureText(coord).width
brain.context.fillStyle = brain.colorFont
brain.context.fillText(coord, brain.widthCanvas.X +
brain.widthCanvas.Y + (brain.widthCanvas.Z / 2) - coordWidth / 2,
Math.round(brain.canvas.height - (brain.sizeFontPixels / 2)))
brain.widthCanvas.Y + (brain.widthCanvas.Z / 2) - coordWidth / 2,
Math.round(brain.canvas.height - (brain.sizeFontPixels / 2)))
}
}
}
Expand Down Expand Up @@ -594,12 +592,12 @@ function brainsprite (params) {
brain.canvas.addEventListener('click', brain.clickBrain, false)

// Attach a listener on mouse down
brain.canvas.addEventListener('mousedown', function (e) {
brain.canvas.addEventListener('mousedown', function () {
brain.canvas.addEventListener('mousemove', brain.clickBrain, false)
}, false)

// Detach the listener on mouse up
brain.canvas.addEventListener('mouseup', function (e) {
brain.canvas.addEventListener('mouseup', function () {
brain.canvas.removeEventListener('mousemove', brain.clickBrain, false)
}, false)

Expand All @@ -622,4 +620,4 @@ function brainsprite (params) {
brain.drawAll()

return brain
};
}

0 comments on commit 5e33f1c

Please sign in to comment.