mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Renamed Align to Center
This commit is contained in:
parent
7c4d03b105
commit
299d4fb895
Before Width: | Height: | Size: 521 B After Width: | Height: | Size: 521 B |
@ -6,7 +6,7 @@
|
||||
new pskl.tools.transform.Flip(),
|
||||
new pskl.tools.transform.Rotate(),
|
||||
new pskl.tools.transform.Clone(),
|
||||
new pskl.tools.transform.Align()
|
||||
new pskl.tools.transform.Center()
|
||||
];
|
||||
|
||||
this.toolIconBuilder = new pskl.tools.ToolIconBuilder();
|
||||
|
@ -1,19 +0,0 @@
|
||||
(function () {
|
||||
var ns = $.namespace('pskl.tools.transform');
|
||||
|
||||
ns.Align = function () {
|
||||
this.toolId = 'tool-align';
|
||||
this.helpText = 'Align selection to the center';
|
||||
this.tooltipDescriptors = [
|
||||
{key : 'ctrl', description : 'Apply to all layers'},
|
||||
{key : 'shift', description : 'Apply to all frames'}
|
||||
];
|
||||
};
|
||||
|
||||
pskl.utils.inherit(ns.Align, ns.AbstractTransformTool);
|
||||
|
||||
ns.Align.prototype.applyToolOnFrame_ = function (frame, altKey) {
|
||||
ns.TransformUtils.align(frame);
|
||||
};
|
||||
|
||||
})();
|
19
src/js/tools/transform/Center.js
Normal file
19
src/js/tools/transform/Center.js
Normal file
@ -0,0 +1,19 @@
|
||||
(function () {
|
||||
var ns = $.namespace('pskl.tools.transform');
|
||||
|
||||
ns.Center = function () {
|
||||
this.toolId = 'tool-center';
|
||||
this.helpText = 'Align image to the center';
|
||||
this.tooltipDescriptors = [
|
||||
{key : 'ctrl', description : 'Apply to all layers'},
|
||||
{key : 'shift', description : 'Apply to all frames'}
|
||||
];
|
||||
};
|
||||
|
||||
pskl.utils.inherit(ns.Center, ns.AbstractTransformTool);
|
||||
|
||||
ns.Center.prototype.applyToolOnFrame_ = function (frame) {
|
||||
ns.TransformUtils.center(frame);
|
||||
};
|
||||
|
||||
})();
|
@ -64,22 +64,20 @@
|
||||
return frame;
|
||||
},
|
||||
|
||||
align : function(frame) {
|
||||
center : function(frame) {
|
||||
// Figure out the boundary
|
||||
var minx = frame.width;
|
||||
var miny = frame.height;
|
||||
var maxx = 0;
|
||||
var maxy = 0;
|
||||
for (var col = 0; col < frame.width; col++) {
|
||||
for (var row = 0; row < frame.height; row++) {
|
||||
if (frame.pixels[col][row] !== Constants.TRANSPARENT_COLOR) {
|
||||
miny = Math.min(miny, row);
|
||||
maxy = Math.max(maxy, row);
|
||||
minx = Math.min(minx, col);
|
||||
maxx = Math.max(maxx, col);
|
||||
}
|
||||
frame.forEachPixel(function (color, x, y) {
|
||||
if (color !== Constants.TRANSPARENT_COLOR) {
|
||||
minx = Math.min(minx, x);
|
||||
maxx = Math.max(maxx, x);
|
||||
miny = Math.min(miny, y);
|
||||
maxy = Math.max(maxy, y);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Calculate how much to move the pixels
|
||||
var bw = (maxx - minx + 1) / 2;
|
||||
|
@ -201,7 +201,7 @@
|
||||
"js/tools/drawing/ColorSwap.js",
|
||||
"js/tools/drawing/DitheringTool.js",
|
||||
"js/tools/transform/AbstractTransformTool.js",
|
||||
"js/tools/transform/Align.js",
|
||||
"js/tools/transform/Center.js",
|
||||
"js/tools/transform/Clone.js",
|
||||
"js/tools/transform/Flip.js",
|
||||
"js/tools/transform/Rotate.js",
|
||||
|
Loading…
Reference in New Issue
Block a user