Screen helpers · interface

PixelCursorOptions

Pixel art from a string grid, as a CSS cursor value.

Explained in Recording and clips.

interface PixelCursorOptions
import type { PixelCursorOptions } from '@driftengine/core';

In depth

Generated rather than shipped as a PNG. Two reasons, and the second is the one that matters: a generated cursor costs no asset and no request, and it can be recoloured at runtime — so it belongs to whatever palette the game is currently wearing instead of being a fixed image that clashes with half of them.

Rendered at the device pixel ratio and declared through image-set, so it is crisp on a retina display. A bitmap authored at 1x is upscaled smoothly by the browser, which is precisely the wrong thing to do to pixel art.

Properties

NameTypeDescription
scalereadonlyoptionalnumberDevice-independent pixels per art pixel.
hotspotXreadonlyoptionalnumberThe art pixel that sits under the pointer. Defaults to the centre.
hotspotYreadonlyoptionalnumber
fallbackreadonlyoptionalstringKeyword used when the image cannot be built.