On this page

## Methods

### 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')

Parameters:

Name | Type | Description
--- | --- | ---
`url` | string | URL for path to image

Source
  - domUtils.js, line 65

Returns:

A promise resolving to the image

Type:
  Promise

### createCanvas(width, height, preferDOMopt) → {Canvas}

Create a blank 2D canvas of a given width/height.

Parameters:

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
  - domUtils.js, line 119

Returns:

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.

Parameters:

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
  - domUtils.js, line 141

Returns:

The resulting Canvas's 2D context

Type:
  Context2D

### setCtxImage(ctx, img)

Fill this context with the given image, resizing it to img size if needed.

Parameters:

Name | Type | Description
--- | --- | ---
`ctx` | Context2D | a canvas 2D context
`img` | Image | the Image to install in this ctx

Source
  - domUtils.js, line 308

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

Parameters:

Name | Type | Description
--- | --- | ---
`obj` | Object | Object who's key/val pairs will be installed in window.

Source
  - domUtils.js, line 322

Type anything to view search result