The 2D layer · type
SpriteImage
The three sources both backends take without a conversion.
Explained in Sprites and tilemaps.
type SpriteImage = ImageBitmap | HTMLCanvasElement | OffscreenCanvasimport type { SpriteImage } from '@driftengine/ui2d';In depth
Narrower than TexImageSource on purpose. WebGPU's copyExternalImageToTexture refuses an
ImageData outright, and an HTMLImageElement is accepted by only some implementations — so
the union that is honestly portable is a bitmap and the two canvases. A caller with an <img>
reaches this through one createImageBitmap, which is also where the decode's own orientation
and premultiply options live, and those are decisions worth making in the open.
All three carry their own width and height, which is the other reason: nothing here has to
ask the caller how big the image it just handed over is.