Methods
createCanvas(width, height, preferDOMopt) → {Canvas}
Create a blank 2D canvas of a given width/height.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
width | number | The canvas height in pixels | ||
height | number | The canvas width in pixels | ||
preferDOM | boolean | <optional> | false | If false, return "Offscreen" canvas |
- Source
The resulting Canvas object
- Type:
- Canvas
createCtx(width, height, offscreenopt) → {Context2D}
As above, but returing the 2D context object instead of the canvas. Note ctx.canvas is the canvas for the ctx, and can be use as an image.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
width | number | The canvas height in pixels | ||
height | number | The canvas width in pixels | ||
offscreen | boolean | <optional> | offscreenOK() | If true, return "Offscreen" canvas |
- Source
The resulting Canvas's 2D context
- Type:
- Context2D
imagePromise(url) → {Promise}
Return a Promise for getting an image.
use: imagePromise('./path/to/img').then(img => imageFcn(img)) or: await imagePromise('./path/to/img')
Name | Type | Description |
---|---|---|
url | string | URL for path to image |
- Source
A promise resolving to the image
- Type:
- Promise
setCtxImage(ctx, img)
Fill this context with the given image, resizing it to img size if needed.
Name | Type | Description |
---|---|---|
ctx | Context2D | a canvas 2D context |
img | Image | the Image to install in this ctx |
- Source
toWindow(obj)
Merge a module's obj key/val pairs into to the global/window namespace. Primary use is to make console logging easier when debugging modules.
Name | Type | Description |
---|---|---|
obj | Object | Object who's key/val pairs will be installed in window. |
- Source