mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 14:46:10 +03:00
split setImageSmoothingEnabled into private and public parts, change floor to round
This commit is contained in:
parent
1e538e665d
commit
ef068e9229
@ -247,7 +247,6 @@ $.Drawer.prototype = {
|
|||||||
var viewportSize = this._calculateCanvasSize();
|
var viewportSize = this._calculateCanvasSize();
|
||||||
if( this.canvas.width != viewportSize.x ||
|
if( this.canvas.width != viewportSize.x ||
|
||||||
this.canvas.height != viewportSize.y ) {
|
this.canvas.height != viewportSize.y ) {
|
||||||
var imageSmoothingEnabled = this.canvas.getContext('2d').imageSmoothingEnabled;
|
|
||||||
this.canvas.width = viewportSize.x;
|
this.canvas.width = viewportSize.x;
|
||||||
this.canvas.height = viewportSize.y;
|
this.canvas.height = viewportSize.y;
|
||||||
if ( this.sketchCanvas !== null ) {
|
if ( this.sketchCanvas !== null ) {
|
||||||
@ -255,7 +254,7 @@ $.Drawer.prototype = {
|
|||||||
this.sketchCanvas.width = sketchCanvasSize.x;
|
this.sketchCanvas.width = sketchCanvasSize.x;
|
||||||
this.sketchCanvas.height = sketchCanvasSize.y;
|
this.sketchCanvas.height = sketchCanvasSize.y;
|
||||||
}
|
}
|
||||||
this.setImageSmoothingEnabled(imageSmoothingEnabled);
|
this._setImageSmoothingEnabled();
|
||||||
}
|
}
|
||||||
this._clear();
|
this._clear();
|
||||||
}
|
}
|
||||||
@ -611,6 +610,9 @@ $.Drawer.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
// private
|
||||||
|
_imageSmoothingEnabled: true,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns image smoothing on or off for this viewer. Note: Ignored in some (especially older) browsers that do not support this property.
|
* Turns image smoothing on or off for this viewer. Note: Ignored in some (especially older) browsers that do not support this property.
|
||||||
*
|
*
|
||||||
@ -621,16 +623,21 @@ $.Drawer.prototype = {
|
|||||||
*/
|
*/
|
||||||
setImageSmoothingEnabled: function(imageSmoothingEnabled){
|
setImageSmoothingEnabled: function(imageSmoothingEnabled){
|
||||||
if ( this.useCanvas ) {
|
if ( this.useCanvas ) {
|
||||||
var context = this.context;
|
this._imageSmoothingEnabled = imageSmoothingEnabled;
|
||||||
context.mozImageSmoothingEnabled = imageSmoothingEnabled;
|
this._setImageSmoothingEnabled();
|
||||||
context.webkitImageSmoothingEnabled = imageSmoothingEnabled;
|
|
||||||
context.msImageSmoothingEnabled = imageSmoothingEnabled;
|
|
||||||
context.imageSmoothingEnabled = imageSmoothingEnabled;
|
|
||||||
|
|
||||||
this.viewer.forceRedraw();
|
this.viewer.forceRedraw();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// private
|
||||||
|
_setImageSmoothingEnabled: function(){
|
||||||
|
var context = this.context;
|
||||||
|
context.mozImageSmoothingEnabled = this._imageSmoothingEnabled;
|
||||||
|
context.webkitImageSmoothingEnabled = this._imageSmoothingEnabled;
|
||||||
|
context.msImageSmoothingEnabled = this._imageSmoothingEnabled;
|
||||||
|
context.imageSmoothingEnabled = this._imageSmoothingEnabled;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the canvas size
|
* Get the canvas size
|
||||||
* @param {Boolean} sketch If set to true return the size of the sketch canvas
|
* @param {Boolean} sketch If set to true return the size of the sketch canvas
|
||||||
@ -689,8 +696,8 @@ $.Drawer.prototype = {
|
|||||||
var viewportSize = this.viewport.getContainerSize();
|
var viewportSize = this.viewport.getContainerSize();
|
||||||
return {
|
return {
|
||||||
// canvas width and height are integers
|
// canvas width and height are integers
|
||||||
x: Math.floor(viewportSize.x * pixelDensityRatio),
|
x: Math.round(viewportSize.x * pixelDensityRatio),
|
||||||
y: Math.floor(viewportSize.y * pixelDensityRatio)
|
y: Math.round(viewportSize.y * pixelDensityRatio)
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user