<sk-morph-spline-source>

← prev index next →

Blends between two other spline-sources by morph-progress — the way to make one curve continuously interpolate into a different curve (a circle relaxing into a square, an SVG glyph flowing into a hand-authored path).

Remarks

This is the compositing member of the spline-source family: a spline-source supplies the curve geometry for a AbstractSpline, so it lives as the single geometry child of a sk-spline. Unlike the leaf sources, this one has no geometry of its own — it wraps TWO other spline-sources and produces the per-vertex linear interpolation between them. Both children are resampled to a matching vertex count (the larger of the two) by arc length, then positions and widths are lerped every frame at the current morph-progress. The children may be any spline-sources — SVG, points, GPU, trail, or even a nested sk-morph-spline-source for recursive composition.

Key attributes. morph-progress is the blend factor in [0, 1]: 0 = the first (source) child exactly, 1 = the second (target) child exactly, and it is animatable, so keyframing it 0 → 1 plays the morph. The two child roles are fixed by DOM order — the FIRST *-spline-source child is the source, the SECOND is the target; exactly two children are required (any other count makes the morph inert). A child that is itself a GPU source (sk-compute-buffer-spline-source, sk-custom-wgsl-spline-source) or a sk-trail-spline-source contributes nothing until it has CPU-side polyline data (first readback / first accumulated points), so the morph renders nothing until BOTH children are ready. Like every spline-source it also carries the family's distribution / distribution-count controls: a spline-source is itself a points-source, so a sk-cloner given one places clones along the blended curve, and these controls choose how it is sampled into those positions.

Related. Its two children are any members of the spline-source family: sk-svg-spline-source, sk-points-spline-source, sk-trail-spline-source, or the GPU sources sk-compute-buffer-spline-source / sk-custom-wgsl-spline-source. Its host is a sk-spline, whose curve then draws with a stroke paint, carries an sk-align-to-spline-constraint, or seeds points and fields — and those consumers see the morph animate as morph-progress sweeps.

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
morph-progressanimatable <number> 0 Initial blend factor in the range 0..1 (0 = source, 1 = target).
distributionanimatable <spline-distribution> ("control-points" | "tessellated" | "arc-length-spaced")
distribution-count <number>