mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
fix : renderer resize on window resize
This commit is contained in:
parent
8a380b6c78
commit
e0d63bf295
@ -10,10 +10,11 @@
|
|||||||
this.setFPS(Constants.DEFAULT.FPS);
|
this.setFPS(Constants.DEFAULT.FPS);
|
||||||
|
|
||||||
var zoom = this.calculateZoom_();
|
var zoom = this.calculateZoom_();
|
||||||
|
var frame = this.piskelController.getCurrentFrame();
|
||||||
var renderingOptions = {
|
var renderingOptions = {
|
||||||
"zoom": zoom,
|
"zoom": zoom,
|
||||||
"height" : this.piskelController.getCurrentFrame().getHeight() * zoom,
|
"height" : frame.getHeight() * zoom,
|
||||||
"width" : this.piskelController.getCurrentFrame().getWidth() * zoom
|
"width" : frame.getWidth() * zoom
|
||||||
};
|
};
|
||||||
this.renderer = new pskl.rendering.frame.FrameRenderer(this.container, renderingOptions);
|
this.renderer = new pskl.rendering.frame.FrameRenderer(this.container, renderingOptions);
|
||||||
|
|
||||||
@ -58,15 +59,18 @@
|
|||||||
* Calculate the preview DPI depending on the framesheet size
|
* Calculate the preview DPI depending on the framesheet size
|
||||||
*/
|
*/
|
||||||
ns.AnimatedPreviewController.prototype.calculateZoom_ = function () {
|
ns.AnimatedPreviewController.prototype.calculateZoom_ = function () {
|
||||||
|
var frame = this.piskelController.getCurrentFrame();
|
||||||
var previewSize = 200,
|
var previewSize = 200,
|
||||||
hZoom = previewSize / this.piskelController.getCurrentFrame().getHeight(),
|
hZoom = previewSize / frame.getHeight(),
|
||||||
wZoom = previewSize / this.piskelController.getCurrentFrame().getWidth();
|
wZoom = previewSize / frame.getWidth();
|
||||||
|
|
||||||
return Math.min(hZoom, wZoom);
|
return Math.min(hZoom, wZoom);
|
||||||
};
|
};
|
||||||
|
|
||||||
ns.AnimatedPreviewController.prototype.updateZoom_ = function () {
|
ns.AnimatedPreviewController.prototype.updateZoom_ = function () {
|
||||||
|
var frame = this.piskelController.getCurrentFrame();
|
||||||
var zoom = this.calculateZoom_();
|
var zoom = this.calculateZoom_();
|
||||||
this.renderer.setZoom(zoom);
|
this.renderer.setZoom(zoom);
|
||||||
|
this.renderer.setDisplaySize(frame.getWidth() * zoom, frame.getHeight() * zoom);
|
||||||
};
|
};
|
||||||
})();
|
})();
|
@ -110,6 +110,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
ns.DrawingController.prototype.onFrameSizeChanged_ = function () {
|
||||||
|
this.compositeRenderer.setZoom(this.calculateZoom_());
|
||||||
|
this.compositeRenderer.setDisplaySize(this.getContainerWidth_(), this.getContainerHeight_());
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
@ -212,7 +212,7 @@
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ns.FrameRenderer.prototype.renderFrame_ = function (frame) {
|
ns.FrameRenderer.prototype.renderFrame_ = function (frame) {
|
||||||
if (!this.canvas) {
|
if (!this.canvas || frame.getWidth() != this.canvas.width || frame.getHeight() != this.canvas.height) {
|
||||||
this.canvas = pskl.CanvasUtils.createCanvas(frame.getWidth(), frame.getHeight());
|
this.canvas = pskl.CanvasUtils.createCanvas(frame.getWidth(), frame.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user