mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Issue #414: part5: rename PiskelController getFrameAt to getMergedFrameAt
This commit is contained in:
parent
186b5a305a
commit
d2dc42e7cf
@ -203,7 +203,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
getFirstFrameAsPng : function () {
|
getFirstFrameAsPng : function () {
|
||||||
var firstFrame = this.piskelController.getFrameAt(0);
|
var firstFrame = this.piskelController.getMergedFrameAt(0);
|
||||||
var firstFrameCanvas = pskl.utils.FrameUtils.toImage(firstFrame);
|
var firstFrameCanvas = pskl.utils.FrameUtils.toImage(firstFrame);
|
||||||
return firstFrameCanvas.toDataURL('image/png');
|
return firstFrameCanvas.toDataURL('image/png');
|
||||||
},
|
},
|
||||||
|
@ -90,7 +90,7 @@
|
|||||||
return this.piskel;
|
return this.piskel;
|
||||||
};
|
};
|
||||||
|
|
||||||
ns.PiskelController.prototype.getFrameAt = function (index) {
|
ns.PiskelController.prototype.getMergedFrameAt = function (index) {
|
||||||
var hash = [];
|
var hash = [];
|
||||||
var frames = this.getLayers().map(function (l) {
|
var frames = this.getLayers().map(function (l) {
|
||||||
var frame = l.getFrameAt(index);
|
var frame = l.getFrameAt(index);
|
||||||
|
@ -170,7 +170,7 @@
|
|||||||
var index = this.getNextIndex_(delta);
|
var index = this.getNextIndex_(delta);
|
||||||
if (this.shoudlRender_() || this.currentIndex != index) {
|
if (this.shoudlRender_() || this.currentIndex != index) {
|
||||||
this.currentIndex = index;
|
this.currentIndex = index;
|
||||||
var frame = this.piskelController.getFrameAt(this.currentIndex);
|
var frame = this.piskelController.getMergedFrameAt(this.currentIndex);
|
||||||
this.renderer.render(frame);
|
this.renderer.render(frame);
|
||||||
this.renderFlag = false;
|
this.renderFlag = false;
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
for (var i = 0 ; i < this.piskelController.getFrameCount() ; i++) {
|
for (var i = 0 ; i < this.piskelController.getFrameCount() ; i++) {
|
||||||
var frame = this.piskelController.getFrameAt(i);
|
var frame = this.piskelController.getMergedFrameAt(i);
|
||||||
var canvasRenderer = new pskl.rendering.CanvasRenderer(frame, zoom);
|
var canvasRenderer = new pskl.rendering.CanvasRenderer(frame, zoom);
|
||||||
if (preserveColors) {
|
if (preserveColors) {
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
ns.PngExportController.prototype.mergedExport_ = function (zip) {
|
ns.PngExportController.prototype.mergedExport_ = function (zip) {
|
||||||
var paddingLength = ('' + this.piskelController.getFrameCount()).length;
|
var paddingLength = ('' + this.piskelController.getFrameCount()).length;
|
||||||
for (var i = 0; i < this.piskelController.getFrameCount(); i++) {
|
for (var i = 0; i < this.piskelController.getFrameCount(); i++) {
|
||||||
var frame = this.piskelController.getFrameAt(i);
|
var frame = this.piskelController.getMergedFrameAt(i);
|
||||||
var canvas = this.getFrameAsCanvas_(frame);
|
var canvas = this.getFrameAsCanvas_(frame);
|
||||||
var basename = this.pngFilePrefixInput.value;
|
var basename = this.pngFilePrefixInput.value;
|
||||||
var id = pskl.utils.StringUtils.leftPad(i, paddingLength, '0');
|
var id = pskl.utils.StringUtils.leftPad(i, paddingLength, '0');
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
ns.PiskelRenderer = function (piskelController) {
|
ns.PiskelRenderer = function (piskelController) {
|
||||||
var frames = [];
|
var frames = [];
|
||||||
for (var i = 0 ; i < piskelController.getFrameCount() ; i++) {
|
for (var i = 0 ; i < piskelController.getFrameCount() ; i++) {
|
||||||
frames.push(piskelController.getFrameAt(i));
|
frames.push(piskelController.getMergedFrameAt(i));
|
||||||
}
|
}
|
||||||
ns.FramesheetRenderer.call(this, frames);
|
ns.FramesheetRenderer.call(this, frames);
|
||||||
};
|
};
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
serializeLayer : function (layer, expanded) {
|
serializeLayer : function (layer, expanded) {
|
||||||
var frames = layer.getFrames();
|
var frames = layer.getFrames();
|
||||||
var renderer = new pskl.rendering.FramesheetRenderer(frames);
|
|
||||||
var layerToSerialize = {
|
var layerToSerialize = {
|
||||||
name : layer.getName(),
|
name : layer.getName(),
|
||||||
opacity : layer.getOpacity(),
|
opacity : layer.getOpacity(),
|
||||||
@ -32,6 +31,7 @@
|
|||||||
layerToSerialize.grids = frames.map(function (f) {return f.pixels;});
|
layerToSerialize.grids = frames.map(function (f) {return f.pixels;});
|
||||||
return layerToSerialize;
|
return layerToSerialize;
|
||||||
} else {
|
} else {
|
||||||
|
var renderer = new pskl.rendering.FramesheetRenderer(frames);
|
||||||
layerToSerialize.base64PNG = renderer.renderAsCanvas().toDataURL();
|
layerToSerialize.base64PNG = renderer.renderAsCanvas().toDataURL();
|
||||||
return JSON.stringify(layerToSerialize);
|
return JSON.stringify(layerToSerialize);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user