feat(shaders): add RadialProgress shader for circular progress / countdown UIs#26
Merged
Conversation
…tdown UIs A new sibling to LinearGradient / RadialGradient that draws a stroked ring filled to a `progress` value, with a gradient swept along the arc, a background track, and configurable round/butt end caps. Implemented for both WebGL and Canvas2D backends. Single-node, one draw call, animatable via `progress: 0..1`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RadialProgressshader — a stroked ring filled to aprogressvalue, with a gradient swept along the arc, an optional backgroundtrackColor, and round or butt end caps. Single-node, one draw call, animatable viaprogress: 0..1.LinearGradient/RadialGradientinexports/{webgl,canvas}-shaders.tsandexamples/common/installShaders.ts.examples/tests/shader-radial-progress.tsshowing six variants (defaults, screenshot-recipe countdown, multi-stop gradient sweep, CCW butt caps, full-circle rainbow, custom start angle).API
```ts
renderer.createShader('RadialProgress', {
width: 14,
progress: 0.7, // 0..1, animatable
startAngle: -Math.PI / 2, // 12 o'clock
direction: 1, // 1 = CW, -1 = CCW
colors: [0x4aa3ffff], // 1..N RGBA swept along the arc
trackColor: 0x1f3a5cff, // 0x00000000 = disabled
cap: 1, // 0 = butt, 1 = round
});
```
Notes for reviewers
RadialGradient?RadialGradientinterpolates by distance from a center (filled disc/ellipse). The countdown ring needs interpolation by angle along a stroked arc — different primitive, different fragment shader. Sibling rather than replacement keeps existingRadialGradientconsumers untouched.vec4(mix(base.rgb, layer.rgb, layer.a), base.a + layer.a*(1-base.a))rather thanvec4(blended, base.a)— this lets the ring render visibly on a node whose basecoloralpha is 0 (transparent background), which is the common case for a standalone progress component.colors/stops. Segments overlap by 2% to avoid AA seams.colors:N|cap:0|1|track:0|1so shader programs are reused across compatible prop variations.Test plan
🤖 Generated with Claude Code