updates to viewer

This commit is contained in:
Tom 2023-12-22 13:46:36 -05:00
parent 1a1e2c20c0
commit 1239b22c30
3 changed files with 11 additions and 5 deletions

View File

@ -62,7 +62,7 @@ class CanvasDrawer extends $.DrawerBase{
this.sketchContext = null;
// Image smoothing for canvas rendering (only if canvas is used).
// Canvas default is "true", so this will only be changed if user specifies "false" in setImageSmoothinEnabled.
// Canvas default is "true", so this will only be changed if user specifies "false" in the options or via setImageSmoothinEnabled.
this._imageSmoothingEnabled = true;
}
@ -138,7 +138,7 @@ class CanvasDrawer extends $.DrawerBase{
* {@link OpenSeadragon.Options} for more explanation.
*/
setImageSmoothingEnabled(imageSmoothingEnabled){
this._imageSmoothingEnabled = imageSmoothingEnabled;
this._imageSmoothingEnabled = !!imageSmoothingEnabled;
this._updateImageSmoothingEnabled(this.context);
this.viewer.forceRedraw();
}

View File

@ -447,6 +447,8 @@ $.Viewer = function( options ) {
}
let drawerCandidates = Array.isArray(this.drawer) ? this.drawer : [this.drawer];
if (drawerCandidates.length === 0){
// if an empty array was passed in, throw a warning and use the defaults
// note: if the drawer option is not specified, the defaults will already be set so this won't apply
drawerCandidates = [$.DEFAULT_SETTINGS.drawer].flat(); // ensure it is a list
$.console.warn('No valid drawers were selected. Using the default value.');
}
@ -487,13 +489,15 @@ $.Viewer = function( options ) {
throw('Error with creating the selected drawer(s)');
}
// Pass the imageSmoothingEnabled option along to the drawer
this.drawer.setImageSmoothingEnabled(this.imageSmoothingEnabled);
// Overlay container
this.overlaysContainer = $.makeNeutralElement( "div" );
this.canvas.appendChild( this.overlaysContainer );
// Now that we have a drawer, see if it supports rotate. If not we need to remove the rotate buttons
if (this.drawer && !this.drawer.canRotate()) {
if (!this.drawer.canRotate()) {
// Disable/remove the rotate left/right buttons since they aren't supported
if (this.rotateLeft) {
i = this.buttonGroup.buttons.indexOf(this.rotateLeft);

View File

@ -392,8 +392,10 @@
* @param {Boolean} enabled
*/
setImageSmoothingEnabled(enabled){
this._clippingContext.imageSmoothingEnabled = enabled;
this._outputContext.imageSmoothingEnabled = enabled;
//TODO: does imageSmoothingEnabled make sense in the WebGL drawer?
// We aren't scaling small images up to larger ones using context2d canvas operations so it may not apply
this._clippingContext.imageSmoothingEnabled = !!enabled;
this._outputContext.imageSmoothingEnabled = !!enabled;
}
/**