TiledPreview : follow up

This commit is contained in:
jdescottes
2014-05-08 20:45:05 +02:00
parent 98135d01f8
commit 6ad5bde5d1
19 changed files with 129 additions and 24108 deletions

View File

@@ -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();
}
};

View File

@@ -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);
}
};
})();