Documentation
    Preparing search index...

    Interface RasterSource

    A surface an application paints and the engine reads (§77a; RFC 0004).

    Structural and DOM-free, in the discipline of TextureSource, FetchLike, PointerSurface, and SurfaceObserver: the engine names a shape, the host supplies a value, and the browser adapter is a few lines in the application — see the module header for it, and for the §33 and §96 rules every source lives under.

    interface RasterSource {
        colorSpace?: ColorSpace;
        height: number;
        origin?: RasterOrigin;
        width: number;
        paint?(): void;
        readPixels(out: Uint8Array): void;
    }

    Implemented by

    Index
    colorSpace?: ColorSpace

    The colour space of the texels this source produces. Default "srgb" — a deliberate difference from TextureSource's "linear" default, with the reason written at both (RFC 0004 Q3, adopted): R-15's linear default exists only so that already-authored textures and their pixel goldens do not move, a class that did not exist then has neither, and a host 2D canvas produces sRGB-encoded bytes unambiguously. Choosing "linear" here for consistency would make the new tier wrong on purpose.

    height: number

    Height in texels. A finite integer ≥ 1. Constant until the application calls CanvasTexture.resize after changing it.

    origin?: RasterOrigin

    Which row RasterSource.readPixels writes first — see RasterOrigin. Default "bottom-left". Read once, at CanvasTexture construction, like the size.

    width: number

    Width in texels. A finite integer ≥ 1. Constant until the application calls CanvasTexture.resize after changing it.

    • Repaint, if this source paints on demand. Called by CanvasTexture.update immediately before RasterSource.readPixels, and — like update() itself — never from a fixed step (§33; see the module header).

      No parameter, deliberately: the source closes over whatever it paints with, and the engine never learns what that is. The hook exists only so the engine can order the repaint against the read.

      Returns void

    • Write exactly width * height * 4 tightly packed RGBA8 bytes into out, straight alpha, in the order declared by RasterSource.origin.

      out is engine-owned and exactly the right length; a source neither allocates nor retains it.

      Parameters

      • out: Uint8Array

      Returns void