createCanvasContext(width, height, willReadFrequently) → OffscreenCanvasRenderingContext2DengineUtilities.js:189Create 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
- Returns
An HTMLCanvasElement's context where there is no OffscreenCanvas, as
in Safari before 16.4, which has the same drawing calls
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
- A top level value whose default is a vec2, a vec3 or a Color, a value with a copy method and only numbers,
comes back as a new one, where JSON keeps only its numbers, a number not saved or not finite the default's;
with nothing saved any value with a copy method is a copy of the default, so changing it leaves the default
- A value whose default is a number, at the top level or inside an array or object default, comes back as the
default when what was saved is not a number, as for Infinity, which JSON writes as null
- An array or object default not saved comes back as a copy, a vec2 or a Color in it too, so changing it leaves
the default; a key a nested object default has that the save has not, a setting added since, is the default's,
and a saved array is the array that was saved, shorter or longer than its default
- Inside an array or object a vec2 or a Color comes back as one too, from its saved numbers, and an object or
array default saved as anything that is not one, an older save's number or a null, comes back as the default, so
a value that may be none is best a default of null, but a vec2 or a Color, which over a null default comes back
as plain numbers with no methods, is best its own default with a flag beside it; a value of a
class with no copy method is the default's own when not saved, and as JSON gave it once saved
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