Take into account the view's resolution in Item#rasterize()

This commit is contained in:
Jürg Lehni 2014-02-26 16:20:19 +01:00
parent ec0877962b
commit c1ccdf6cb7

View file

@ -1522,7 +1522,9 @@ var Item = Base.extend(Callback, /** @lends Item# */{
* Rasterizes the item into a newly created Raster object. The item itself * Rasterizes the item into a newly created Raster object. The item itself
* is not removed after rasterization. * is not removed after rasterization.
* *
* @param {Number} [resolution=72] the resolution of the raster in dpi * @param {Number} [resolution=view.resolution] the resolution of the raster
* in pixels per inch (DPI). If not speceified, the value of
* {@code view.resolution} is used.
* @return {Raster} the newly created raster item * @return {Raster} the newly created raster item
* *
* @example {@paperscript} * @example {@paperscript}
@ -1545,7 +1547,8 @@ var Item = Base.extend(Callback, /** @lends Item# */{
*/ */
rasterize: function(resolution) { rasterize: function(resolution) {
var bounds = this.getStrokeBounds(), var bounds = this.getStrokeBounds(),
scale = (resolution || 72) / 72, view = this._project.view,
scale = (resolution || view && view.getResolution() || 72) / 72,
// Floor top-left corner and ceil bottom-right corner, to never // Floor top-left corner and ceil bottom-right corner, to never
// blur or cut pixels. // blur or cut pixels.
topLeft = bounds.getTopLeft().floor(), topLeft = bounds.getTopLeft().floor(),