diff --git a/js/_drawLine.js b/js/_drawLine.js index e7ce712..f0365ec 100644 --- a/js/_drawLine.js +++ b/js/_drawLine.js @@ -1,4 +1,4 @@ -//draw a line between two points on canvas +//draws a line between two points on canvas function line(x0,y0,x1,y1, brushSize) { var dx = Math.abs(x1-x0); var dy = Math.abs(y1-y0); diff --git a/js/_editorMode.js b/js/_editorMode.js index e89626c..8ed2bc7 100644 --- a/js/_editorMode.js +++ b/js/_editorMode.js @@ -3,7 +3,7 @@ let modes = { description: 'Basic mode is perfect if you want to create simple sprites or try out palettes.' }, 'Advanced' : { - description: 'Choose advanced mode to gain access to features such as layers.' + description: 'Choose advanced mode to gain access to more advanced features such as layers.' } } diff --git a/js/_fileMenu.js b/js/_fileMenu.js index f680dcf..35e2037 100644 --- a/js/_fileMenu.js +++ b/js/_fileMenu.js @@ -18,8 +18,6 @@ for (var i = 1; i < mainMenuItems.length; i++) { var subMenu = menuItem.children[1]; var subMenuItems = subMenu.children; - - //when you click an item within a menu button for (var j = 0; j < subMenuItems.length; j++) { diff --git a/js/_fill.js b/js/_fill.js index aa8a7d9..22d0f44 100644 --- a/js/_fill.js +++ b/js/_fill.js @@ -7,11 +7,6 @@ function fill(cursorLocation) { tempImage.data[pixelPos + 1] = fillColor.g; tempImage.data[pixelPos + 2] = fillColor.b; tempImage.data[pixelPos + 3] = 255; - /* - tempImage.data[pixelPos] = fillColor.r; - tempImage.data[pixelPos + 1] = fillColor.g; - tempImage.data[pixelPos + 2] = fillColor.b; - */ } //change x y to color value passed from the function and use that as the original color diff --git a/js/_getCursorPosition.js b/js/_getCursorPosition.js index 4c9cdca..6aaed4e 100644 --- a/js/_getCursorPosition.js +++ b/js/_getCursorPosition.js @@ -1,4 +1,4 @@ -//get cursor position relative to canvas +//gets cursor position relative to canvas function getCursorPosition(e) { var x; var y; diff --git a/js/_history.js b/js/_history.js index 656d05d..0f554c3 100644 --- a/js/_history.js +++ b/js/_history.js @@ -1,3 +1,17 @@ +/** How the history works + * - undoStates stores the states that can be undone + * - redoStates stores the states that can be redone + * - undo() undoes an action and adds it to the redoStates + * - redo() redoes an action and adds it to the undoStates + * - Each HistoryState must implement an undo() and redo() function + * Those functions actually implement the undo and redo mechanism for that action, + * so you'll need to save the data you need as attributes in the constructor. For example, + * for the HistoryStateAddColour, the added colour is saved so that it can be removed in + * undo() or added back in redo(). + * - Each HistoryState must call saveHistoryState(this) so that it gets added to the stack + * + */ + var undoStates = []; var redoStates = []; @@ -473,8 +487,6 @@ function saveHistoryState (state) { } function undo () { - //console.log('%cundo', undoLogStyle); - //if there are any states saved to undo if (undoStates.length > 0) { document.getElementById('redo-button').classList.remove('disabled'); @@ -496,8 +508,6 @@ function undo () { } function redo () { - //console.log('%credo', undoLogStyle); - if (redoStates.length > 0) { //enable undo button diff --git a/js/_hotkeyListener.js b/js/_hotkeyListener.js index 73ea4bc..d156758 100644 --- a/js/_hotkeyListener.js +++ b/js/_hotkeyListener.js @@ -1,5 +1,9 @@ var spacePressed = false; +/** Just listens to hotkeys and calls the linked functions + * + * @param {*} e + */ function KeyPress(e) { var keyboardEvent = window.event? event : e; diff --git a/js/_initColor.js b/js/_initColor.js index 955abf4..c1bcf60 100644 --- a/js/_initColor.js +++ b/js/_initColor.js @@ -1,5 +1,7 @@ +// NEXTPULL: to remove when the new palette system is added -//format a color button + +//formats a color button function initColor (colorElement) { //console.log('initColor()'); //console.log(document.getElementById('jscolor-hex-input')) diff --git a/js/_jscolor.js b/js/_jscolor.js index e6c8c3b..2cbf910 100644 --- a/js/_jscolor.js +++ b/js/_jscolor.js @@ -1,3 +1,5 @@ +// NEXTPULL: to remove when the new palette system is added + /** * jscolor - JavaScript Color Picker * diff --git a/js/_layer.js b/js/_layer.js index d270bc4..2882cb7 100644 --- a/js/_layer.js +++ b/js/_layer.js @@ -1,31 +1,27 @@ -/** TODO LIST FOR LAYERS - - GENERAL REQUIREMENTS: - - Saving the state of an artwork to a .lospec file so that people can work on it later keeping - the layers they created? That'd be cool, even for the app users, that could just double click on a lospec - file for it to be opened right in the pixel editor - - OPTIONAL: - - 1 - Fix issues -*/ - +// HTML element that contains the layer entries let layerList; +// A single layer entry (used as a prototype to create the new ones) let layerListEntry; - +// NEXTPULL: remove the drag n drop system and use Sortable.js instead let layerDragSource = null; +// Number of layers at the beginning let layerCount = 1; +// Current max z index (so that I know which z-index to assign to new layers) let maxZIndex = 3; +// When a layer is deleted, its id is added to this array and can be reused let unusedIDs = []; +// Id for the next added layer let currentID = layerCount; -let idToDelete; +// Layer menu let layerOptions = document.getElementById("layer-properties-menu"); - +// Is the user currently renaming a layer? let isRenamingLayer = false; +// I need to save this, trust me let oldLayerName = null; +// Binding the add layer button to the function on('click',"add-layer-button", addLayer, false); /** Handler class for a single canvas (a single layer) @@ -54,6 +50,7 @@ class Layer { this.id = "layer" + id; + // Binding the events if (menuEntry != null) { this.name = menuEntry.getElementsByTagName("p")[0].innerHTML; menuEntry.id = "layer" + id; @@ -78,20 +75,13 @@ class Layer { // Initializes the canvas initialize() { - /* - var maxHorizontalZoom = Math.floor(window.innerWidth/this.canvasSize[0]*0.75); - var maxVerticalZoom = Math.floor(window.innerHeight/this.canvasSize[1]*0.75); - - zoom = Math.min(maxHorizontalZoom,maxVerticalZoom); - if (zoom < 1) zoom = 1; - */ //resize canvas this.canvas.width = this.canvasSize[0]; this.canvas.height = this.canvasSize[1]; this.canvas.style.width = (this.canvas.width*zoom)+'px'; this.canvas.style.height = (this.canvas.height*zoom)+'px'; - //unhide canvas + //show canvas this.canvas.style.display = 'block'; //center canvas in window @@ -103,7 +93,7 @@ class Layer { } hover() { - // Hide all the layers but the current one + // Hides all the layers but the current one for (let i=1; i