mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
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:
@@ -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;
|
||||
|
||||
@@ -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'
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user