Class: Drawer

OpenSeadragon.Drawer

Handles rendering of tiles for an OpenSeadragon.Viewer.

Constructor

new Drawer(options)

Parameters:
Name Type Description
options Object Options for this Drawer.
Properties
Name Type Attributes Description
viewer OpenSeadragon.Viewer The Viewer that owns this Drawer.
viewport OpenSeadragon.Viewport Reference to Viewer viewport.
element Element Parent element.
debugGridColor Number <optional>
See debugGridColor in OpenSeadragon.Options for details.
Source:

Members

canvas :Element

A <canvas> element if the browser supports them, otherwise a <div> element. Child element of OpenSeadragon.Drawer#container.
Type:
  • Element
Source:

container :Element

The parent element of this Drawer instance, passed in when the Drawer was created. The parent of OpenSeadragon.Drawer#canvas.
Type:
  • Element
Source:

context :Object

2d drawing context for OpenSeadragon.Drawer#canvas if it's a <canvas> element, otherwise null.
Type:
  • Object
Source:

element :Element

Type:
  • Element
Deprecated:
Source:

Methods

blendSketch(options)

Blends the sketch canvas in the main canvas.
Parameters:
Name Type Description
options Object The options
Properties
Name Type Attributes Default Description
opacity Float The opacity of the blending.
scale Float <optional>
1 The scale at which tiles were drawn on the sketch. Default is 1. Use scale to draw at a lower scale and then enlarge onto the main canvas.
translate OpenSeadragon.Point <optional>
A translation vector that was used to draw the tiles
compositeOperation String <optional>
How the image is composited onto other images; see compositeOperation in OpenSeadragon.Options for possible values.
bounds OpenSeadragon.Rect <optional>
The part of the sketch canvas to blend in the main canvas. If specified, options.scale and options.translate get ignored.
Source:

canRotate() → {Boolean}

Source:
Returns:
True if rotation is supported.
Type
Boolean

clear()

Clears the Drawer so it's ready to draw another frame.
Source:

clipWithPolygons(polygons, useSketch)

This function will create multiple polygon paths on the drawing context by provided polygons, then clip the context to the paths.
Parameters:
Name Type Description
polygons Array.<Array.<OpenSeadragon.Point>> an array of polygons. A polygon is an array of OpenSeadragon.Point
useSketch Boolean Whether to use the sketch canvas or not.
Source:

destroy()

Destroy the drawer (unload current loaded tiles)
Source:

drawTile(tile, drawingHandler, useSketch, scaleopt, translateopt, shouldRoundPositionAndSizeopt, source)

Draws the given tile.
Parameters:
Name Type Attributes Default Description
tile OpenSeadragon.Tile The tile to draw.
drawingHandler function Method for firing the drawing event if using canvas. drawingHandler({context, tile, rendered})
useSketch Boolean Whether to use the sketch canvas or not. where rendered is the context with the pre-drawn image.
scale Float <optional>
1 Apply a scale to tile position and size. Defaults to 1.
translate OpenSeadragon.Point <optional>
A translation vector to offset tile position
shouldRoundPositionAndSize Boolean <optional>
Tells whether to round position and size of tiles supporting alpha channel in non-transparency context.
source OpenSeadragon.TileSource The source specification of the tile.
Source:

getCanvasSize(sketch) → {OpenSeadragon.Point}

Get the canvas size
Parameters:
Name Type Description
sketch Boolean If set to true return the size of the sketch canvas
Source:
Returns:
The size of the canvas
Type
OpenSeadragon.Point

getOpacity() → {Number}

Get the opacity of the drawer.
Source:
Returns:
Type
Number

setImageSmoothingEnabled(imageSmoothingEnabledopt)

Turns image smoothing on or off for this viewer. Note: Ignored in some (especially older) browsers that do not support this property.
Parameters:
Name Type Attributes Description
imageSmoothingEnabled Boolean <optional>
Whether or not the image is drawn smoothly on the canvas; see imageSmoothingEnabled in OpenSeadragon.Options for more explanation.
Source:

setOpacity(opacity) → {OpenSeadragon.Drawer}

Set the opacity of the drawer.
Parameters:
Name Type Description
opacity Number
Source:
Returns:
Chainable.
Type
OpenSeadragon.Drawer

viewportCoordToDrawerCoord(point) → {OpenSeadragon.Point}

This function converts the given point from to the drawer coordinate by multiplying it with the pixel density. This function does not take rotation into account, thus assuming provided point is at 0 degree.
Parameters:
Name Type Description
point OpenSeadragon.Point the pixel point to convert
Source:
Returns:
Point in drawer coordinate system.
Type
OpenSeadragon.Point

viewportToDrawerRectangle(rectangle) → {OpenSeadragon.Rect}

Scale from OpenSeadragon viewer rectangle to drawer rectangle (ignoring rotation)
Parameters:
Name Type Description
rectangle OpenSeadragon.Rect The rectangle in viewport coordinate system.
Source:
Returns:
Rectangle in drawer coordinate system.
Type
OpenSeadragon.Rect