@mocanvas/editor · interface

AssetContext

interface AssetContext

How an asset is about to be used, so a store can serve a resolution- or bandwidth-appropriate variant instead of always handing back the original.

Every field has a sensible value in DEFAULT_ASSET_CONTEXT, so a store that only ever returns one URL can ignore the whole object.


Properties · 5

dpr: number

devicePixelRatio of the surface the asset will be painted on.

networkEffectiveType: string | null

navigator.connection.effectiveType when the browser reports it, otherwise null.

screenScale: number

How large one page unit is on screen right now: camera zoom times device pixel ratio.

shouldResolveToOriginal: boolean

True for copy, paste and export, where a downscaled variant would lose data.

steppedScreenScale: number

screenScale snapped to a power of two, so a drag-resize does not re-request every frame.

Mentioned here

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.