Files
hyperframes/skills/hyperframes-animation/rules/svg-path-draw.md
T
WaterrrForever 853256403b feat(skills): c2v mining pass — 7 new blueprints, 10 new rules, compacted recipe corpus (#2680)
* feat(skills): c2v mining pass over animation blueprints and rules

Compacts ~45 existing animation rules/blueprints into tighter recipe form
(net -3.4k lines) and adds 17 mined from the c2v corpus:

- 7 blueprints: agent-progress-theater, camera-journey, fixed-anchor-cycle,
  panel-edit-live-sync, prompt-type-submit-generate,
  transcript-scroll-artifact-reveal, zoom-out-workspace-reveal
- 10 rules: 3d-camera-flight, anchored-layout-expand, chart-scrub-readout,
  chromatic-glitch, control-target-sync, cursor-drag, gradient-text-sweep,
  multi-cursor-choreography, particle-burst, theme-crossfade-morph






Both indexes updated.

* feat(skills): sync product-launch script bank with mined blueprint roles

The role->blueprint script bank in product-launch-video/story-design.md is
kept 1:1 with blueprints-index role declarations, which the c2v mining pass
expanded. Adds the 25 missing entries (script-shape descriptor + example
lines + pattern): 13 for the 7 new blueprints, 12 for role widenings on 7
existing ones (cursor-ui-demo, dataviz-countup, titlecard-reveal, et al.),
and states the 1:1 sync contract in the bank's intro.

* docs(skills): cover constellation-hub scatter-drift variant in the script bank

Review follow-up on #2680: the SOCIAL_PROOF constellation-hub entry
patterned only the orbit shape; the c2v pass added a scatter-drift
end-card variant with the opposite geometry (no hub, no ring). Adds an
example line and extends the pattern so a scatter-drift beat's VO isn't
steered toward the orbit shape.
2026-07-21 17:28:55 +08:00

5.2 KiB
Raw Blame History

name, description, metadata
name description metadata
svg-path-draw Animate SVG paths drawing progressively using stroke-dasharray and stroke-dashoffset.
tags
svg, stroke, draw, path, reveal, icon, vector

SVG Path Draw

Reveals an SVG shape by animating its stroke as if a pen were tracing it. Two stroke properties together: stroke-dasharray = <pathLength> makes the entire path one dash; stroke-dashoffset starts at the path length (dash shifted fully out of view → invisible) and tweens to 0 (fully drawn). The length comes from the DOM API path.getTotalLength() — measured, never guessed.

Works on anything with a stroke: <path>, <circle>, <rect>, <line>, <polyline>, <polygon>, <ellipse>.

Recipe

<!-- inside a standard scene clip -->
<svg class="logo-mark" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
  <path id="bar-left" d="M 60 40 L 60 160" />
  <path id="bar-right" d="M 140 40 L 140 160" />
  <path id="bar-mid" d="M 60 100 L 140 100" />
</svg>
.logo-mark path {
  fill: none; /* outline-only draw — a fill would appear immediately and ruin the reveal */
  stroke: {accentColor};
  stroke-width: 12;
  stroke-linecap: round; /* softer endpoints */
  stroke-linejoin: round;
}
// Setup: measure each path and set its dash pattern. Real measured geometry, not a magic number.
document.querySelectorAll(".logo-mark path").forEach((p) => {
  const len = p.getTotalLength();
  p.style.strokeDasharray = `${len}`;
  p.style.strokeDashoffset = `${len}`;
});

// Stagger draws so the eye reads continuous motion — each segment starts at
// ~70-80% of the previous segment's duration, before it finishes.
tl.to(
  "#bar-left",
  { strokeDashoffset: 0, duration: SEGMENT_DRAW_DUR, ease: "power2.out" },
  SEG_1_START,
);
tl.to(
  "#bar-right",
  { strokeDashoffset: 0, duration: SEGMENT_DRAW_DUR, ease: "power2.out" },
  SEG_2_START,
);
tl.to(
  "#bar-mid",
  { strokeDashoffset: 0, duration: FINAL_SEGMENT_DUR, ease: "power2.out" },
  SEG_3_START,
);

// Companion wordmark fades in only after the last stroke settles.
tl.to(
  ".brand-line",
  { opacity: 1, duration: BRAND_FADE_DUR, ease: "power1.out" },
  BRAND_FADE_START,
);

Variations

  • Ring starting at 12 o'clock<circle> / <rect> strokes start at 3 o'clock by default; rotate the element -90deg so a progress ring draws from the top:
<circle
  cx="100"
  cy="100"
  r="60"
  id="ring"
  style="transform-origin: 100px 100px; transform: rotate(-90deg)"
/>
  • Linear (constant-speed) drawease: "none" for a steady-rate "real pen" trace.
  • Draw then fill — for filled shapes, tween fillOpacity: 0 → 1 AFTER the stroke completes (requires fill-opacity: 0 initially and a real fill in CSS):
tl.to(
  "#path",
  { strokeDashoffset: 0, duration: SEGMENT_DRAW_DUR, ease: "power2.out" },
  SEG_1_START,
);
tl.to(
  "#path",
  { fillOpacity: 1, duration: FILL_FADE_DUR, ease: "power1.out" },
  SEG_1_START + SEGMENT_DRAW_DUR,
);

Values

token range notes
SEGMENT_DRAW_DUR 0.30.8s fast snap vs deliberate pen trace; >~1s feels sluggish for a logo reveal
FINAL_SEGMENT_DUR 6080% of SEGMENT_DRAW_DUR proportional to segment length — a short connector at full duration reads slower than its siblings
SEG_N_START previous start + 7080% of its duration reads as continuous motion, not N isolated animations
SEG_1_START 00.4s a small ~0.2s lead-in lets the viewer settle before motion
BRAND_FADE_START ≥ last stroke end (+ ~0.2s beat) earlier and the wordmark competes with the draw
BRAND_FADE_DUR 0.30.8s snap (urgent) vs glide (premium)

Ease families are discrete choices: stroke draws use power2.out (a hand lifting at end of stroke) or none for constant speed — never back.out / elastic.out (pens don't bounce). Fades use power1.out.

Critical Constraints

  • fill: none for outline-only draws — otherwise the fill appears immediately.
  • Dasharray/dashoffset = the measured getTotalLength(), set at setup; requires the SVG in the DOM (inline SVG is fine; a loaded <image> SVG is not).
  • Complex paths: if getTotalLength() looks wrong, overestimate slightly (len * 1.05) — too large is invisible at animation start; too small clips the end.
  • Stagger multi-path draws at ~7080% of the previous segment's duration.

See also

svg-icon-enrichment (internal parts animate after the outline draws) · counting-dynamic-scale (stroke draws an icon while a number counts up) · hacker-flip-3d (logo draws, wordmark decodes beneath).