<sk-raster-color-source>

← prev index next →

Paints a material's base color straight from an image — projecting a loaded raster onto a surface like a slide projector — the way to stamp a logo, decal, or texture onto geometry instead of computing the color.

Remarks

This is the image-driven member of the ColorSource family: like every color-source it gives a material a base color that varies across the surface, but instead of computing that color it samples a loaded raster and returns the texel's RGBA — including its alpha — wherever the source applies. It is a full scene node, so its own transform and every ancestor's carries the image, and it projects with foreshortening: a tilted source narrows its decal on the receiving surface, never widens it.

Key attributes. src is the image URL (http(s), relative, or a data: URI); SVG sources are rasterized and sampled like any other. projection-plane is a signed two-axis token (default xz) mapping image u/v onto world axes — a standing XY surface reads upright with x-y. width/height size one raster copy in local units (0 = AUTO: width → one unit, height → the image's aspect ratio); anchor (a box keyword or content(x, y) in image pixels, default center) sits at the source's local origin. tile is none (one bounded decal, default) or repeat (seamless tiling). visualize draws the projection quad so the placement is visible while composing.

Projection & loading. With projection="auto" (default) the paint drives the parametrization — stroke paints project stroke-parametrically, surface paints planarly; projection="uv" samples the mesh's authored texture coordinates instead. The raster loads asynchronously: until it arrives the flat base-color shows through, and a load event re-renders the consumers once texel data is available. Scene readiness does not await the load.

Related. A material selects it with base-color-source="#id" (see sk-plain-material). Its scalar-driven sibling is sk-color-map-source; to layer it under or over other sources, use sk-composite-color-source (at most one raster child per material).

Serve these docs to run the live example. WebGPU needs a secure context — open this page via grunt serve rather than double-clicking the file. The Markup tab works from disk.

Attributes

AttributeTypeDefaultDescription
id <id> The element's unique identifier — the standard HTML global id attribute.
srcrequired <string> The raster URL (http(s)/relative/data:). Assigning starts a load.
projection <raster-projection> ("auto" | "uv") "auto" Projection mode.
projection-plane <coordinate-space> "xz" The signed 2-axis <coordinate-space> token naming which LOCAL axes
tileanimatable <raster-tile> ("none" | "repeat") "none" Tile mode outside the unit uv square (a params flag — data-only).
widthanimatable <number> 0 Local units one raster copy spans along u — or, sampled from a stroke
heightanimatable <number> 0 Local units one raster copy spans along v. 0 = AUTO: derived from the
anchor <content-anchor> (<anchor>) "center" The image point pinned to the source's local origin: a box-anchor
fieldanimatable <id-ref> Gets the optional applicability field that masks where this source reference by id
xanimatable <number> 0 Gets the X position component.
yanimatable <number> 0 Gets the Y position component.
zanimatable <number> 0 Gets the Z position component.
hanimatable <angle> 0 Gets the heading (Y-axis) rotation in radians.
panimatable <angle> 0 Gets the pitch (X-axis) rotation in radians.
banimatable <angle> 0 Gets the bank (Z-axis) rotation in radians.
visualize <boolean> false Whether the visualization is visible (wireframe splines + center marker).
interactive-controls <boolean> false Whether interactive controls are shown (draggable markers for adjusting parameters).