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:

destroy()

Destroy the drawer (unload current loaded tiles)
Source:

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

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
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

setOpacity(opacity) → {OpenSeadragon.Drawer}

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

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