mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
TiledPreview : follow up
This commit is contained in:
@@ -159,9 +159,11 @@
|
||||
return hex.length == 1 ? "0" + hex : hex;
|
||||
},
|
||||
|
||||
toImage : function (frame) {
|
||||
var canvasRenderer = new pskl.rendering.CanvasRenderer(frame, 1);
|
||||
canvasRenderer.drawTransparentAs(Constants.TRANSPARENT_COLOR);
|
||||
toImage : function (frame, zoom, bgColor) {
|
||||
zoom = zoom || 1;
|
||||
bgColor = bgColor || Constants.TRANSPARENT_COLOR;
|
||||
var canvasRenderer = new pskl.rendering.CanvasRenderer(frame, zoom);
|
||||
canvasRenderer.drawTransparentAs(bgColor);
|
||||
return canvasRenderer.render();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -156,22 +156,6 @@
|
||||
*/
|
||||
calculateZoomForContainer : function (container, pictureHeight, pictureWidth) {
|
||||
return this.calculateZoom(container.height(), container.width(), pictureHeight, pictureWidth);
|
||||
},
|
||||
|
||||
/**
|
||||
* Calculate and return the maximal zoom to display a picture for a given height and width.
|
||||
*
|
||||
* @param height number Height available to display the picture
|
||||
* @param width number Width available to display the picture
|
||||
* @param number pictureHeight height in pixels of the picture to display
|
||||
* @param number pictureWidth width in pixels of the picture to display
|
||||
* @return number maximal zoom
|
||||
*/
|
||||
calculateZoom : function (height, width, pictureHeight, pictureWidth) {
|
||||
var heightRatio = Math.floor(height / pictureHeight),
|
||||
widthRatio = Math.floor(width / pictureWidth);
|
||||
|
||||
return Math.min(heightRatio, widthRatio);
|
||||
}
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user