mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Make jshint quiet now
This commit is contained in:
@@ -57,5 +57,5 @@
|
|||||||
ns.AnimatedPreviewController.prototype.updateDPI_ = function () {
|
ns.AnimatedPreviewController.prototype.updateDPI_ = function () {
|
||||||
this.dpi = this.calculateDPI_();
|
this.dpi = this.calculateDPI_();
|
||||||
this.renderer.updateDPI(this.dpi);
|
this.renderer.updateDPI(this.dpi);
|
||||||
}
|
};
|
||||||
})();
|
})();
|
@@ -173,7 +173,7 @@
|
|||||||
*/
|
*/
|
||||||
ns.DrawingController.prototype.wrapEvtInfo_ = function (event) {
|
ns.DrawingController.prototype.wrapEvtInfo_ = function (event) {
|
||||||
var evtInfo = {};
|
var evtInfo = {};
|
||||||
if (event.button == 0) {
|
if (event.button === 0) {
|
||||||
evtInfo.button = Constants.LEFT_BUTTON;
|
evtInfo.button = Constants.LEFT_BUTTON;
|
||||||
} else if (event.button == 2) {
|
} else if (event.button == 2) {
|
||||||
evtInfo.button = Constants.RIGHT_BUTTON;
|
evtInfo.button = Constants.RIGHT_BUTTON;
|
||||||
|
@@ -53,7 +53,7 @@
|
|||||||
}
|
}
|
||||||
this.container.append(this.createInterstitialTile_(frameCount));
|
this.container.append(this.createInterstitialTile_(frameCount));
|
||||||
|
|
||||||
var needDragndropBehavior = !!(frameCount > 1);
|
var needDragndropBehavior = (frameCount > 1) ? true : false;
|
||||||
if(needDragndropBehavior) {
|
if(needDragndropBehavior) {
|
||||||
this.initDragndropBehavior_();
|
this.initDragndropBehavior_();
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
*/
|
*/
|
||||||
ns.PreviewFilmController.prototype.createInterstitialTile_ = function (tileNumber) {
|
ns.PreviewFilmController.prototype.createInterstitialTile_ = function (tileNumber) {
|
||||||
var interstitialTile = document.createElement("div");
|
var interstitialTile = document.createElement("div");
|
||||||
interstitialTile.className = "interstitial-tile"
|
interstitialTile.className = "interstitial-tile";
|
||||||
interstitialTile.setAttribute("data-tile-type", "interstitial");
|
interstitialTile.setAttribute("data-tile-type", "interstitial");
|
||||||
interstitialTile.setAttribute("data-inject-drop-tile-at", tileNumber);
|
interstitialTile.setAttribute("data-inject-drop-tile-at", tileNumber);
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@
|
|||||||
canvasPreviewDeleteAction.setAttribute('rel', 'tooltip');
|
canvasPreviewDeleteAction.setAttribute('rel', 'tooltip');
|
||||||
canvasPreviewDeleteAction.setAttribute('data-placement', 'right');
|
canvasPreviewDeleteAction.setAttribute('data-placement', 'right');
|
||||||
canvasPreviewDeleteAction.setAttribute('title', 'Delete this frame');
|
canvasPreviewDeleteAction.setAttribute('title', 'Delete this frame');
|
||||||
canvasPreviewDeleteAction.className = "tile-action delete-frame-action"
|
canvasPreviewDeleteAction.className = "tile-action delete-frame-action";
|
||||||
canvasPreviewDeleteAction.addEventListener('click', this.onDeleteButtonClick_.bind(this, tileNumber));
|
canvasPreviewDeleteAction.addEventListener('click', this.onDeleteButtonClick_.bind(this, tileNumber));
|
||||||
previewTileRoot.appendChild(canvasPreviewDeleteAction);
|
previewTileRoot.appendChild(canvasPreviewDeleteAction);
|
||||||
actionContainer.appendChild(canvasPreviewDeleteAction);
|
actionContainer.appendChild(canvasPreviewDeleteAction);
|
||||||
|
@@ -46,27 +46,27 @@
|
|||||||
|
|
||||||
var pixels = [];
|
var pixels = [];
|
||||||
var dx = Math.abs(x1-x0);
|
var dx = Math.abs(x1-x0);
|
||||||
var dy = Math.abs(y1-y0);
|
var dy = Math.abs(y1-y0);
|
||||||
var sx = (x0 < x1) ? 1 : -1;
|
var sx = (x0 < x1) ? 1 : -1;
|
||||||
var sy = (y0 < y1) ? 1 : -1;
|
var sy = (y0 < y1) ? 1 : -1;
|
||||||
var err = dx-dy;
|
var err = dx-dy;
|
||||||
|
|
||||||
while(true){
|
while(true){
|
||||||
|
|
||||||
// Do what you need to for this
|
// Do what you need to for this
|
||||||
pixels.push({"col": x0, "row": y0});
|
pixels.push({"col": x0, "row": y0});
|
||||||
|
|
||||||
if ((x0==x1) && (y0==y1)) break;
|
if ((x0==x1) && (y0==y1)) break;
|
||||||
var e2 = 2*err;
|
var e2 = 2*err;
|
||||||
if (e2>-dy){
|
if (e2>-dy){
|
||||||
err -= dy;
|
err -= dy;
|
||||||
x0 += sx;
|
x0 += sx;
|
||||||
}
|
}
|
||||||
if (e2 < dx) {
|
if (e2 < dx) {
|
||||||
err += dx;
|
err += dx;
|
||||||
y0 += sy;
|
y0 += sy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pixels;
|
return pixels;
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
var ns = $.namespace("pskl.drawingtools");
|
var ns = $.namespace("pskl.drawingtools");
|
||||||
|
|
||||||
ns.Move = function() {
|
ns.Move = function() {
|
||||||
this.toolId = "tool-move"
|
this.toolId = "tool-move";
|
||||||
this.helpText = "Move tool";
|
this.helpText = "Move tool";
|
||||||
|
|
||||||
// Stroke's first point coordinates (set in applyToolAt)
|
// Stroke's first point coordinates (set in applyToolAt)
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
} else {
|
} else {
|
||||||
color = Constants.TRANSPARENT_COLOR;
|
color = Constants.TRANSPARENT_COLOR;
|
||||||
}
|
}
|
||||||
frame.setPixel(col, row, color)
|
frame.setPixel(col, row, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -5,9 +5,9 @@
|
|||||||
this.toolId = "tool-vertical-mirror-pen";
|
this.toolId = "tool-vertical-mirror-pen";
|
||||||
this.helpText = "vertical mirror pen tool";
|
this.helpText = "vertical mirror pen tool";
|
||||||
|
|
||||||
this.swap = null
|
this.swap = null;
|
||||||
this.mirroredPreviousCol = null;
|
this.mirroredPreviousCol = null;
|
||||||
this.mirroredPreviousRow = null;
|
this.mirroredPreviousRow = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
pskl.utils.inherit(ns.VerticalMirrorPen, ns.SimplePen);
|
pskl.utils.inherit(ns.VerticalMirrorPen, ns.SimplePen);
|
||||||
|
@@ -103,7 +103,7 @@
|
|||||||
} else {
|
} else {
|
||||||
color = Constants.TRANSPARENT_COLOR;
|
color = Constants.TRANSPARENT_COLOR;
|
||||||
}
|
}
|
||||||
overlayFrame.setPixel(col, row, color)
|
overlayFrame.setPixel(col, row, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -45,7 +45,7 @@
|
|||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
ns.RectangleSelect.prototype.onSelectEnd_ = function (col, row, color, frame, overlay) {
|
ns.RectangleSelect.prototype.onSelectEnd_ = function (col, row, color, frame, overlay) {
|
||||||
this.onSelect_(col, row, color, frame, overlay)
|
this.onSelect_(col, row, color, frame, overlay);
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
ns.Frame.createEmpty = function (width, height) {
|
ns.Frame.createEmpty = function (width, height) {
|
||||||
var pixels = ns.Frame.createEmptyPixelGrid_(width, height);
|
var pixels = ns.Frame.createEmptyPixelGrid_(width, height);
|
||||||
return new ns.Frame(pixels);
|
return new ns.Frame(pixels);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
columnArray.push(Constants.TRANSPARENT_COLOR);
|
columnArray.push(Constants.TRANSPARENT_COLOR);
|
||||||
}
|
}
|
||||||
pixels[columnIndex] = columnArray;
|
pixels[columnIndex] = columnArray;
|
||||||
}
|
}
|
||||||
return pixels;
|
return pixels;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
* Returns a copy of the pixels used by the frame
|
* Returns a copy of the pixels used by the frame
|
||||||
*/
|
*/
|
||||||
ns.Frame.prototype.getPixels = function () {
|
ns.Frame.prototype.getPixels = function () {
|
||||||
return this.clonePixels_(this.pixels)
|
return this.clonePixels_(this.pixels);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -70,9 +70,9 @@
|
|||||||
*/
|
*/
|
||||||
ns.FrameSheet.prototype.deserialize = function (serialized) {
|
ns.FrameSheet.prototype.deserialize = function (serialized) {
|
||||||
try {
|
try {
|
||||||
this.load(JSON.parse(serialized));
|
this.load(JSON.parse(serialized));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw "Could not load serialized framesheet : " + e.message
|
throw "Could not load serialized framesheet : " + e.message;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -83,20 +83,20 @@
|
|||||||
* @param {String} serialized
|
* @param {String} serialized
|
||||||
*/
|
*/
|
||||||
ns.FrameSheet.prototype.load = function (framesheet) {
|
ns.FrameSheet.prototype.load = function (framesheet) {
|
||||||
this.frames = [];
|
this.frames = [];
|
||||||
for (var i = 0 ; i < framesheet.length ; i++) {
|
for (var i = 0 ; i < framesheet.length ; i++) {
|
||||||
var frameCfg = framesheet[i];
|
var frameCfg = framesheet[i];
|
||||||
this.addFrame(new ns.Frame(frameCfg));
|
this.addFrame(new ns.Frame(frameCfg));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasFrameAtIndex(0)) {
|
if (this.hasFrameAtIndex(0)) {
|
||||||
this.height = this.getFrameByIndex(0).getHeight();
|
this.height = this.getFrameByIndex(0).getHeight();
|
||||||
this.width = this.getFrameByIndex(0).getWidth();
|
this.width = this.getFrameByIndex(0).getWidth();
|
||||||
this.setCurrentFrameIndex(0);
|
this.setCurrentFrameIndex(0);
|
||||||
$.publish(Events.FRAME_SIZE_CHANGED);
|
$.publish(Events.FRAME_SIZE_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
$.publish(Events.FRAMESHEET_RESET);
|
$.publish(Events.FRAMESHEET_RESET);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -148,8 +148,8 @@
|
|||||||
|
|
||||||
ns.FrameSheet.prototype.swapFrames = function(indexFrame1, indexFrame2) {
|
ns.FrameSheet.prototype.swapFrames = function(indexFrame1, indexFrame2) {
|
||||||
if(isNaN(indexFrame1) || isNaN(indexFrame1) ||
|
if(isNaN(indexFrame1) || isNaN(indexFrame1) ||
|
||||||
(!this.hasFrameAtIndex(indexFrame1) && !this.hasFrameAtIndex(indexFrame2))) {
|
(!this.hasFrameAtIndex(indexFrame1) && !this.hasFrameAtIndex(indexFrame2))) {
|
||||||
throw "Bad indexes for swapFrames Framesheet function.";
|
throw "Bad indexes for swapFrames Framesheet function.";
|
||||||
}
|
}
|
||||||
if(indexFrame1 == indexFrame2) {
|
if(indexFrame1 == indexFrame2) {
|
||||||
return;
|
return;
|
||||||
|
@@ -33,4 +33,4 @@
|
|||||||
var height = this.frame.getHeight() * this.dpi;
|
var height = this.frame.getHeight() * this.dpi;
|
||||||
return pskl.CanvasUtils.createCanvas(width, height);
|
return pskl.CanvasUtils.createCanvas(width, height);
|
||||||
};
|
};
|
||||||
})()
|
})();
|
@@ -50,9 +50,12 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
ns.DrawingLoop.prototype.getRequestAnimationFrameShim_ = function () {
|
ns.DrawingLoop.prototype.getRequestAnimationFrameShim_ = function () {
|
||||||
var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
|
var requestAnimationFrame = window.requestAnimationFrame ||
|
||||||
window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) {window.setTimeout(callback, 1000/60)};
|
window.mozRequestAnimationFrame ||
|
||||||
|
window.webkitRequestAnimationFrame ||
|
||||||
|
window.msRequestAnimationFrame ||
|
||||||
|
function (callback) { window.setTimeout(callback, 1000/60); };
|
||||||
|
|
||||||
return requestAnimationFrame;
|
return requestAnimationFrame;
|
||||||
}
|
};
|
||||||
})()
|
})();
|
@@ -8,7 +8,7 @@
|
|||||||
};
|
};
|
||||||
renderingOptions = $.extend(true, {}, this.defaultRenderingOptions, renderingOptions);
|
renderingOptions = $.extend(true, {}, this.defaultRenderingOptions, renderingOptions);
|
||||||
|
|
||||||
if(container == undefined) {
|
if(container === undefined) {
|
||||||
throw "Bad FrameRenderer initialization. <container> undefined.";
|
throw "Bad FrameRenderer initialization. <container> undefined.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,15 +78,15 @@
|
|||||||
/**
|
/**
|
||||||
* Transform a screen pixel-based coordinate (relative to the top-left corner of the rendered
|
* Transform a screen pixel-based coordinate (relative to the top-left corner of the rendered
|
||||||
* frame) into a sprite coordinate in column and row.
|
* frame) into a sprite coordinate in column and row.
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
ns.FrameRenderer.prototype.convertPixelCoordinatesIntoSpriteCoordinate = function(coords) {
|
ns.FrameRenderer.prototype.convertPixelCoordinatesIntoSpriteCoordinate = function(coords) {
|
||||||
var cellSize = this.dpi + this.gridStrokeWidth;
|
var cellSize = this.dpi + this.gridStrokeWidth;
|
||||||
return {
|
return {
|
||||||
"col" : (coords.x - coords.x % cellSize) / cellSize,
|
"col" : (coords.x - coords.x % cellSize) / cellSize,
|
||||||
"row" : (coords.y - coords.y % cellSize) / cellSize
|
"row" : (coords.y - coords.y % cellSize) / cellSize
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -103,15 +103,15 @@
|
|||||||
ctx.lineWidth = Constants.GRID_STROKE_WIDTH;
|
ctx.lineWidth = Constants.GRID_STROKE_WIDTH;
|
||||||
ctx.strokeStyle = Constants.GRID_STROKE_COLOR;
|
ctx.strokeStyle = Constants.GRID_STROKE_COLOR;
|
||||||
for(var c=1; c < col; c++) {
|
for(var c=1; c < col; c++) {
|
||||||
ctx.moveTo(this.getFramePos_(c), 0);
|
ctx.moveTo(this.getFramePos_(c), 0);
|
||||||
ctx.lineTo(this.getFramePos_(c), height);
|
ctx.lineTo(this.getFramePos_(c), height);
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var r=1; r < row; r++) {
|
for(var r=1; r < row; r++) {
|
||||||
ctx.moveTo(0, this.getFramePos_(r));
|
ctx.moveTo(0, this.getFramePos_(r));
|
||||||
ctx.lineTo(width, this.getFramePos_(r));
|
ctx.lineTo(width, this.getFramePos_(r));
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO : (Julz) Mutualize with code already present in FrameRenderer
|
* TODO(juliandescottes): Mutualize with code already present in FrameRenderer
|
||||||
*/
|
*/
|
||||||
ns.SpritesheetRenderer.prototype.drawFrameInCanvas_ = function (frame, canvas, offsetWidth, offsetHeight) {
|
ns.SpritesheetRenderer.prototype.drawFrameInCanvas_ = function (frame, canvas, offsetWidth, offsetHeight) {
|
||||||
var context = canvas.getContext('2d');
|
var context = canvas.getContext('2d');
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
var height = this.framesheet.getHeight();
|
var height = this.framesheet.getHeight();
|
||||||
return pskl.CanvasUtils.createCanvas(width, height);
|
return pskl.CanvasUtils.createCanvas(width, height);
|
||||||
} else {
|
} else {
|
||||||
throw "Cannot render empty Spritesheet"
|
throw "Cannot render empty Spritesheet";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
movedPixel = this.pixels[i];
|
movedPixel = this.pixels[i];
|
||||||
movedPixel.col += colDiff;
|
movedPixel.col += colDiff;
|
||||||
movedPixel.row += rowDiff;
|
movedPixel.row += rowDiff;
|
||||||
movedPixels.push(movedPixel)
|
movedPixels.push(movedPixel);
|
||||||
}
|
}
|
||||||
this.pixels = movedPixels;
|
this.pixels = movedPixels;
|
||||||
};
|
};
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
for(var i=0, l=this.pixels.length; i<l; i++) {
|
for(var i=0, l=this.pixels.length; i<l; i++) {
|
||||||
pixelWithCopiedColor = this.pixels[i];
|
pixelWithCopiedColor = this.pixels[i];
|
||||||
pixelWithCopiedColor.copiedColor =
|
pixelWithCopiedColor.copiedColor =
|
||||||
targetFrame.getPixel(pixelWithCopiedColor.col, pixelWithCopiedColor.row);
|
targetFrame.getPixel(pixelWithCopiedColor.col, pixelWithCopiedColor.row);
|
||||||
}
|
}
|
||||||
this.hasPastedContent = true;
|
this.hasPastedContent = true;
|
||||||
};
|
};
|
||||||
|
@@ -1,22 +1,22 @@
|
|||||||
(function () {
|
(function () {
|
||||||
var ns = $.namespace("pskl");
|
var ns = $.namespace("pskl");
|
||||||
|
|
||||||
ns.CanvasUtils = {
|
ns.CanvasUtils = {
|
||||||
createCanvas : function (width, height, classList) {
|
createCanvas : function (width, height, classList) {
|
||||||
var canvas = document.createElement("canvas");
|
var canvas = document.createElement("canvas");
|
||||||
canvas.setAttribute("width", width);
|
canvas.setAttribute("width", width);
|
||||||
canvas.setAttribute("height", height);
|
canvas.setAttribute("height", height);
|
||||||
|
|
||||||
if (typeof classList == "string") {
|
if (typeof classList == "string") {
|
||||||
classList = [classList];
|
classList = [classList];
|
||||||
}
|
}
|
||||||
if (Array.isArray(classList)) {
|
if (Array.isArray(classList)) {
|
||||||
for (var i = 0 ; i < classList.length ; i++) {
|
for (var i = 0 ; i < classList.length ; i++) {
|
||||||
canvas.classList.add(classList[i]);
|
canvas.classList.add(classList[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return canvas;
|
return canvas;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
@@ -101,8 +101,9 @@
|
|||||||
var queue = [];
|
var queue = [];
|
||||||
var dy = [-1, 0, 1, 0];
|
var dy = [-1, 0, 1, 0];
|
||||||
var dx = [0, 1, 0, -1];
|
var dx = [0, 1, 0, -1];
|
||||||
|
var targetColor;
|
||||||
try {
|
try {
|
||||||
var targetColor = frame.getPixel(col, row);
|
targetColor = frame.getPixel(col, row);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
// Frame out of bound exception.
|
// Frame out of bound exception.
|
||||||
}
|
}
|
||||||
@@ -123,8 +124,8 @@
|
|||||||
paintedPixels.push({"col": currentItem.col, "row": currentItem.row });
|
paintedPixels.push({"col": currentItem.col, "row": currentItem.row });
|
||||||
|
|
||||||
for (var i = 0; i < 4; i++) {
|
for (var i = 0; i < 4; i++) {
|
||||||
var nextCol = currentItem.col + dx[i]
|
var nextCol = currentItem.col + dx[i];
|
||||||
var nextRow = currentItem.row + dy[i]
|
var nextRow = currentItem.row + dy[i];
|
||||||
try {
|
try {
|
||||||
if (frame.containsPixel(nextCol, nextRow) && frame.getPixel(nextCol, nextRow) == targetColor) {
|
if (frame.containsPixel(nextCol, nextRow) && frame.getPixel(nextCol, nextRow) == targetColor) {
|
||||||
queue.push({"col": nextCol, "row": nextRow });
|
queue.push({"col": nextCol, "row": nextRow });
|
||||||
@@ -136,7 +137,7 @@
|
|||||||
|
|
||||||
// Security loop breaker:
|
// Security loop breaker:
|
||||||
if(loopCount > 10 * cellCount) {
|
if(loopCount > 10 * cellCount) {
|
||||||
console.log("loop breaker called")
|
console.log("loop breaker called");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user