mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,6 +1,9 @@
|
||||
# mac artefacts
|
||||
*.DS_Store
|
||||
|
||||
# nodejs local installs
|
||||
node_modules
|
||||
|
||||
# sublime text stuff (the -project should actually be shared, but then we'd have to share the same disk location)
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"evil": true,
|
||||
"asi": true,
|
||||
"smarttabs": true,
|
||||
"eqnull": true
|
||||
}
|
||||
28
Gruntfile.js
28
Gruntfile.js
@@ -1,15 +1,29 @@
|
||||
/**
|
||||
* How to run grunt tasks:
|
||||
* - At project root, run 'npm install' - It will install nodedependencies declared in package,json in <root>/.node_modules
|
||||
* - install grunt CLI tools globally, run 'npm install -g grunt-cli'
|
||||
* - run a grunt target defined in Gruntfiles.js, ex: 'grunt lint'
|
||||
*
|
||||
* Note: The 'ghost' grunt task have special deps on CasperJS and phantomjs.
|
||||
* For now, It's configured to run only on TravisCI where these deps are
|
||||
* correctly defined.
|
||||
* If you run this task locally, it may require some env set up first.
|
||||
*/
|
||||
|
||||
module.exports = function(grunt) {
|
||||
grunt.initConfig({
|
||||
jshint: {
|
||||
options: {
|
||||
jshintrc: '.jshintrc'
|
||||
},
|
||||
/*options: {
|
||||
"evil": true,
|
||||
"asi": true,
|
||||
"smarttabs": true,
|
||||
"eqnull": true
|
||||
},*/
|
||||
files: [
|
||||
'Gruntfile.js',
|
||||
'package.json',
|
||||
// TODO(grosbouddha): change to js/**/*.js and fix the 10K jshint
|
||||
// error messages or fine-tune .jshintrc file.
|
||||
'js/*.js'
|
||||
'js/**/*.js',
|
||||
'!js/lib/**/*.js' // Exclude lib folder (note the leading !)
|
||||
]
|
||||
},
|
||||
connect: {
|
||||
@@ -41,6 +55,6 @@ module.exports = function(grunt) {
|
||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
grunt.loadNpmTasks('grunt-ghost');
|
||||
|
||||
grunt.registerTask('lint', ['jshint']);
|
||||
grunt.registerTask('test', ['jshint', 'connect', 'ghost']);
|
||||
|
||||
};
|
||||
|
||||
@@ -57,5 +57,5 @@
|
||||
ns.AnimatedPreviewController.prototype.updateDPI_ = function () {
|
||||
this.dpi = this.calculateDPI_();
|
||||
this.renderer.updateDPI(this.dpi);
|
||||
}
|
||||
};
|
||||
})();
|
||||
@@ -173,7 +173,7 @@
|
||||
*/
|
||||
ns.DrawingController.prototype.wrapEvtInfo_ = function (event) {
|
||||
var evtInfo = {};
|
||||
if (event.button == 0) {
|
||||
if (event.button === 0) {
|
||||
evtInfo.button = Constants.LEFT_BUTTON;
|
||||
} else if (event.button == 2) {
|
||||
evtInfo.button = Constants.RIGHT_BUTTON;
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
}
|
||||
this.container.append(this.createInterstitialTile_(frameCount));
|
||||
|
||||
var needDragndropBehavior = !!(frameCount > 1);
|
||||
var needDragndropBehavior = (frameCount > 1) ? true : false;
|
||||
if(needDragndropBehavior) {
|
||||
this.initDragndropBehavior_();
|
||||
}
|
||||
@@ -64,7 +64,7 @@
|
||||
*/
|
||||
ns.PreviewFilmController.prototype.createInterstitialTile_ = function (tileNumber) {
|
||||
var interstitialTile = document.createElement("div");
|
||||
interstitialTile.className = "interstitial-tile"
|
||||
interstitialTile.className = "interstitial-tile";
|
||||
interstitialTile.setAttribute("data-tile-type", "interstitial");
|
||||
interstitialTile.setAttribute("data-inject-drop-tile-at", tileNumber);
|
||||
|
||||
@@ -206,7 +206,7 @@
|
||||
canvasPreviewDeleteAction.setAttribute('rel', 'tooltip');
|
||||
canvasPreviewDeleteAction.setAttribute('data-placement', 'right');
|
||||
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));
|
||||
previewTileRoot.appendChild(canvasPreviewDeleteAction);
|
||||
actionContainer.appendChild(canvasPreviewDeleteAction);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
var ns = $.namespace("pskl.drawingtools");
|
||||
|
||||
ns.Move = function() {
|
||||
this.toolId = "tool-move"
|
||||
this.toolId = "tool-move";
|
||||
this.helpText = "Move tool";
|
||||
|
||||
// Stroke's first point coordinates (set in applyToolAt)
|
||||
@@ -40,7 +40,7 @@
|
||||
} else {
|
||||
color = Constants.TRANSPARENT_COLOR;
|
||||
}
|
||||
frame.setPixel(col, row, color)
|
||||
frame.setPixel(col, row, color);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
this.toolId = "tool-vertical-mirror-pen";
|
||||
this.helpText = "vertical mirror pen tool";
|
||||
|
||||
this.swap = null
|
||||
this.swap = null;
|
||||
this.mirroredPreviousCol = null;
|
||||
this.mirroredPreviousRow = null;
|
||||
};
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
} else {
|
||||
color = Constants.TRANSPARENT_COLOR;
|
||||
}
|
||||
overlayFrame.setPixel(col, row, color)
|
||||
overlayFrame.setPixel(col, row, color);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
* @override
|
||||
*/
|
||||
ns.RectangleSelect.prototype.onSelectEnd_ = function (col, row, color, frame, overlay) {
|
||||
this.onSelect_(col, row, color, frame, overlay)
|
||||
this.onSelect_(col, row, color, frame, overlay);
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
* Returns a copy of the pixels used by the frame
|
||||
*/
|
||||
ns.Frame.prototype.getPixels = function () {
|
||||
return this.clonePixels_(this.pixels)
|
||||
return this.clonePixels_(this.pixels);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
try {
|
||||
this.load(JSON.parse(serialized));
|
||||
} catch (e) {
|
||||
throw "Could not load serialized framesheet : " + e.message
|
||||
throw "Could not load serialized framesheet : " + e.message;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -33,4 +33,4 @@
|
||||
var height = this.frame.getHeight() * this.dpi;
|
||||
return pskl.CanvasUtils.createCanvas(width, height);
|
||||
};
|
||||
})()
|
||||
})();
|
||||
@@ -50,9 +50,12 @@
|
||||
};
|
||||
|
||||
ns.DrawingLoop.prototype.getRequestAnimationFrameShim_ = function () {
|
||||
var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) {window.setTimeout(callback, 1000/60)};
|
||||
var requestAnimationFrame = window.requestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function (callback) { window.setTimeout(callback, 1000/60); };
|
||||
|
||||
return requestAnimationFrame;
|
||||
}
|
||||
})()
|
||||
};
|
||||
})();
|
||||
@@ -8,7 +8,7 @@
|
||||
};
|
||||
renderingOptions = $.extend(true, {}, this.defaultRenderingOptions, renderingOptions);
|
||||
|
||||
if(container == undefined) {
|
||||
if(container === undefined) {
|
||||
throw "Bad FrameRenderer initialization. <container> undefined.";
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
var context = canvas.getContext('2d');
|
||||
@@ -41,7 +41,7 @@
|
||||
var height = this.framesheet.getHeight();
|
||||
return pskl.CanvasUtils.createCanvas(width, height);
|
||||
} else {
|
||||
throw "Cannot render empty Spritesheet"
|
||||
throw "Cannot render empty Spritesheet";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
movedPixel = this.pixels[i];
|
||||
movedPixel.col += colDiff;
|
||||
movedPixel.row += rowDiff;
|
||||
movedPixels.push(movedPixel)
|
||||
movedPixels.push(movedPixel);
|
||||
}
|
||||
this.pixels = movedPixels;
|
||||
};
|
||||
|
||||
@@ -101,8 +101,9 @@
|
||||
var queue = [];
|
||||
var dy = [-1, 0, 1, 0];
|
||||
var dx = [0, 1, 0, -1];
|
||||
var targetColor;
|
||||
try {
|
||||
var targetColor = frame.getPixel(col, row);
|
||||
targetColor = frame.getPixel(col, row);
|
||||
} catch(e) {
|
||||
// Frame out of bound exception.
|
||||
}
|
||||
@@ -123,8 +124,8 @@
|
||||
paintedPixels.push({"col": currentItem.col, "row": currentItem.row });
|
||||
|
||||
for (var i = 0; i < 4; i++) {
|
||||
var nextCol = currentItem.col + dx[i]
|
||||
var nextRow = currentItem.row + dy[i]
|
||||
var nextCol = currentItem.col + dx[i];
|
||||
var nextRow = currentItem.row + dy[i];
|
||||
try {
|
||||
if (frame.containsPixel(nextCol, nextRow) && frame.getPixel(nextCol, nextRow) == targetColor) {
|
||||
queue.push({"col": nextCol, "row": nextRow });
|
||||
@@ -136,7 +137,7 @@
|
||||
|
||||
// Security loop breaker:
|
||||
if(loopCount > 10 * cellCount) {
|
||||
console.log("loop breaker called")
|
||||
console.log("loop breaker called");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"test": "grunt test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt": "0.4.1",
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-contrib-connect": "0.3.0",
|
||||
"grunt-contrib-jshint": "0.5.4",
|
||||
"grunt-ghost": "1.0.12"
|
||||
|
||||
Reference in New Issue
Block a user