createCanvasContext(width, height, willReadFrequently) → OffscreenCanvasRenderingContext2DengineUtilities.js:177Create an offscreen canvas to draw into, and return its 2D context
- The canvas is context.canvas, which is what TextureInfo and the like take
- A browser with no OffscreenCanvas, Safari before 16.4, gets a canvas element that is not on the page
width numberIn pixels
height number optionalIn pixels, defaults to the width for a square
willReadFrequently boolean optional, default falseKeep it in software, faster when getImageData is called on it often
Fetches a JSON file from a URL and returns the parsed JSON object. Must be used with await!
url stringURL of JSON file
- Returns
- The parsed JSON, any shape, as response.json() gives it
1D value noise — returns a smooth value in [0, 1] for any real x.
Integer inputs land on deterministic lattice values; non-integer inputs
are interpolated with smoothStep for C1 continuity.
x number
2D value noise — returns a smooth value in [0, 1] for any real (x, y)
x numbery number
Read save data from local storage
- The result has the type of defaultSaveData, or any when there is none
saveName stringunique name for the game/save
defaultSaveData T optionaldefault values, result is {...default, ...loaded} so this must be an object
Share content using the native share dialog if available
title stringtitle of the share
url stringurl to share
callback function optionalCalled when share is complete
Write save data to local storage, an object as readSaveData gives it back
saveName stringunique name for the game/save
saveData objectobject containing data to be saved
- Returns
- Whether it was written, false when storage is unavailable or full