Class: Drawable
A drawable represents the image data for an engraving (e.g. on a plate) and can draw itself onto a 2D canvas context. It is assumed that one drawable instance can be shared by multiple Ornaments using it.
Hierarchy
- Drawable
Index
Properties
Methods
- _createTexture
- _initializeTexture
- canDrawSync
- drawAsync
- drawSync
- filledToCanvas
- getCutoutTexture
- getImage
- getLoadedPromise
- getPhysicalSize
- getSize
- getTexture
- toCanvas
Properties
Private cutoutTexture
• cutoutTexture: Texture = null
Defined in src/model/visualization/textures/drawables/Drawable.ts:27
Protected image
• image: HTMLImageElement = null
Defined in src/model/visualization/textures/drawables/Drawable.ts:25
Private loadedPromise
• loadedPromise: Promise‹void› = Promise.resolve()
Defined in src/model/visualization/textures/drawables/Drawable.ts:28
Private texture
• texture: Texture = new Texture()
Defined in src/model/visualization/textures/drawables/Drawable.ts:26
Methods
Protected _createTexture
▸ _createTexture(): void
Defined in src/model/visualization/textures/drawables/Drawable.ts:173
Subclasses must call this to ensure that the texture is set
Returns: void
Protected _initializeTexture
▸ _initializeTexture(texture: Texture): void
Defined in src/model/visualization/textures/drawables/Drawable.ts:188
Parameters:
| Name | Type |
|---|---|
texture |
Texture |
Returns: void
canDrawSync
▸ canDrawSync(): boolean
Defined in src/model/visualization/textures/drawables/Drawable.ts:79
Return whether drawSync can be called
Returns: boolean
drawAsync
▸ drawAsync(params: IDrawParameters): object
Defined in src/model/visualization/textures/drawables/Drawable.ts:64
Draw asynchronously. Return a promise that indicates when we are finished.
Parameters:
| Name | Type |
|---|---|
params |
IDrawParameters |
Returns: object
-
cancelFn(): function
-
(): void
-
drawPromise: Promise‹void›
drawSync
▸ drawSync(params: IDrawParameters): void
Defined in src/model/visualization/textures/drawables/Drawable.ts:87
Renders the drawable into context, centered around dx, dy.
Parameters:
| Name | Type | Description |
|---|---|---|
params |
IDrawParameters | {@see IDrawParameters} specifying the draw. |
Returns: void
filledToCanvas
▸ filledToCanvas(): Promise‹HTMLCanvasElement›
Defined in src/model/visualization/textures/drawables/Drawable.ts:120
Used for cutouts: Draw the drawable to the canvas by filling the area it includes black. This will be used as a texture for the gpu to decide where the surface should be transparent. Mainly used with {@see SvgDrawable}
Returns: Promise‹HTMLCanvasElement›
getCutoutTexture
▸ getCutoutTexture(): Texture
Defined in src/model/visualization/textures/drawables/Drawable.ts:50
Returns: Texture
THREE Texture of the drawable that's used for cutout-rendering. Should be black / white only, black means this spot should be transparent.
Abstract getImage
▸ getImage(): Promise‹HTMLImageElement›
Defined in src/model/visualization/textures/drawables/Drawable.ts:33
This method will load an image and return it as an HTMLImageElement.
Returns: Promise‹HTMLImageElement›
getLoadedPromise
▸ getLoadedPromise(): Promise‹void›
Defined in src/model/visualization/textures/drawables/Drawable.ts:42
Returns: Promise‹void›
getPhysicalSize
▸ getPhysicalSize(): Promise‹IDimensions2›
Defined in src/model/visualization/textures/drawables/Drawable.ts:157
Returns: Promise‹IDimensions2›
the native physical size (in mm) of the drawable (override in subclasses if your data type knows this!). If not overwritten, tries to estimate the physical size by assuming a 72 dpi conversion factor
getSize
▸ getSize(): Promise‹IDimensions2›
Defined in src/model/visualization/textures/drawables/Drawable.ts:148
Return a promise that resolves to the natural size of the drawable. The natural size is in CSS pixel units.
Returns: Promise‹IDimensions2›
getTexture
▸ getTexture(): Texture
Defined in src/model/visualization/textures/drawables/Drawable.ts:38
Returns: Texture
THREE Texture of the drawable
toCanvas
▸ toCanvas(): Promise‹HTMLCanvasElement›
Defined in src/model/visualization/textures/drawables/Drawable.ts:127
Create a canvas and draw own content to that.
Returns: Promise‹HTMLCanvasElement›