WGSLColorUniform

← prev index next →

Feeds a colour into your custom WGSL shader as a named uniform — authored the way every Skenra colour is (color="#E0A85A", "coral", "rgba(…)") instead of four hand-converted linear-RGBA floats.

Remarks

This is the colour member of the shader-input family that belongs to the compute & custom-WGSL concept (AbstractComputeNode), and — modeled on ColorStop — it is itself a SkenraAnimatable. The authored colour string is parsed and linearised through the standard colour path, so the shader receives it in straight-alpha LINEAR RGBA (RGB through the inverse-sRGB transfer, alpha unchanged) — exactly the space custom-WGSL colour kernels expect. It packs as a single vec4<f32> reusing the vec4 ABI, so the generated accessor is skUniform_<name>() -> vec4<f32>; the author never hand-converts a colour to floats again.

Key attributes. name is a non-animatable WGSL identifier, unique per host — changing it (or adding/removing/reordering uniforms) re-keys the shader. color is the animatable colour: it accepts the CSS colour subset the Skenra parser supports (the four hex lengths, legacy comma rgb()/rgba() and hsl()/hsla(), the oklab() subset, named colours, and transparent) plus var(--…), is optional (an absent colour is a valid transparent uniform), and interpolates as straight-alpha linear-RGB — the standard colour-interpolation contract, not a raw per-component lerp. An invalid colour throws.

Related. It is a child of any custom-WGSL host — sk-custom-wgsl-color-source, sk-custom-wgsl-points-source, sk-custom-wgsl-point-constraint, sk-custom-wgsl-spline-source, or sk-compute-node. For a raw four-lane value use sk-wgsl-vec4-uniform; for other inputs see sk-wgsl-uniform, sk-wgsl-vec2-uniform, sk-wgsl-vec3-uniform, and sk-wgsl-f32-array-uniform.

Constructor

constructor()

Properties

Other Properties

PropertyTypeDefaultDescriptionDeclared by
coloranimatable ColorBase Gets the colour, returning the animated value when animating. WGSLColorUniform
baseColorread-only ColorBase Gets the base (non-animated) colour value. WGSLColorUniform
name string "" Gets the WGSL identifier this member is addressed by. AbstractWGSLUniformMemberElement
sceneread-only any Gets the Scene this animatable belongs to, if any. SkenraAnimatable
animationsread-only SkenraAnimation[] Public getter for the animations affecting this target. SkenraAnimatable

Methods

MethodDescriptionDeclared by
animate(firstArg: TypedKeyframe<this>[] | TypedPropertyIndexedKeyframes<this> | Record<string, any> | globalThis.Keyframe[] | globalThis.PropertyIndexedKeyframes | null, secondArg?: number | KeyframeAnimationOptions | globalThis.KeyframeAnimationOptions): SkenraAnimation & Animation Creates a new SkenraAnimation for this target per Web Animations API. SkenraAnimatable
removeAnimation(animation: SkenraAnimation): boolean Removes a specific animation from this object. SkenraAnimatable
constrain(type: K, config: ConstraintConfigMap[K]): ConstraintReturnMap[K] Creates a constraint on this Animatable using a fluent API. SkenraAnimatable

Example

const u = document.createElement('sk-wgsl-color-uniform') as WGSLColorUniform;
u.name = 'dot7Color';
u.color = '#E0A85A';