feature : change grid size

* removed SHOW_GRID boolean, replaced with GRID_WIDTH
* gridEnabled on a frame is now infered from the grid width setting
* updated template to use a select to pick the grid size
This commit is contained in:
jdescottes
2014-03-16 22:46:43 +01:00
parent c38300392e
commit 9ae01cb074
11 changed files with 49 additions and 35 deletions

View File

@@ -31,7 +31,7 @@
* @param {Number} margin gap to be displayed between pixels
* @return {Canvas2d} the resized canvas
*/
resizeNearestNeighbour : function (source, zoom, margin) {
resizeNearestNeighbour : function (source, zoom, margin, marginColor) {
margin = margin || 0;
var canvas = pskl.CanvasUtils.createCanvas(zoom*source.width, zoom*source.height);
var context = canvas.getContext('2d');
@@ -65,6 +65,12 @@
context.fillStyle = "rgba(" + r + "," + g + "," + b + "," + (a / 255) + ")";
context.fillRect(xOffset, yOffset, xRange-margin, yRange-margin);
if (margin && marginColor) {
context.fillStyle = marginColor;
context.fillRect(xOffset + xRange - margin, yOffset, margin, yRange);
context.fillRect(xOffset, yOffset + yRange - margin, xRange, margin);
}
yOffset += yRange;
}
yOffset = 0;

View File

@@ -2,12 +2,11 @@
var ns = $.namespace("pskl");
ns.UserSettings = {
SHOW_GRID : 'SHOW_GRID',
GRID_WIDTH : 'GRID_WIDTH',
CANVAS_BACKGROUND : 'CANVAS_BACKGROUND',
KEY_TO_DEFAULT_VALUE_MAP_ : {
'SHOW_GRID' : false,
'GRID_WIDTH' : 0,
'CANVAS_BACKGROUND' : 'medium-canvas-background'
},