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);
|
||||
|
||||
var zoom = this.calculateZoom_();
|
||||
var frame = this.piskelController.getCurrentFrame();
|
||||
var renderingOptions = {
|
||||
"zoom": zoom,
|
||||
"height" : this.piskelController.getCurrentFrame().getHeight() * zoom,
|
||||
"width" : this.piskelController.getCurrentFrame().getWidth() * zoom
|
||||
"height" : frame.getHeight() * zoom,
|
||||
"width" : frame.getWidth() * zoom
|
||||
};
|
||||
this.renderer = new pskl.rendering.frame.FrameRenderer(this.container, renderingOptions);
|
||||
|
||||
@ -58,15 +59,18 @@
|
||||
* Calculate the preview DPI depending on the framesheet size
|
||||
*/
|
||||
ns.AnimatedPreviewController.prototype.calculateZoom_ = function () {
|
||||
var frame = this.piskelController.getCurrentFrame();
|
||||
var previewSize = 200,
|
||||
hZoom = previewSize / this.piskelController.getCurrentFrame().getHeight(),
|
||||
wZoom = previewSize / this.piskelController.getCurrentFrame().getWidth();
|
||||
hZoom = previewSize / frame.getHeight(),
|
||||
wZoom = previewSize / frame.getWidth();
|
||||
|
||||
return Math.min(hZoom, wZoom);
|
||||
};
|
||||
|
||||
ns.AnimatedPreviewController.prototype.updateZoom_ = function () {
|
||||
var frame = this.piskelController.getCurrentFrame();
|
||||
var zoom = this.calculateZoom_();
|
||||
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
|
||||
*/
|
||||
|
@ -212,7 +212,7 @@
|
||||
* @private
|
||||
*/
|
||||
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());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user