---
name: newscene-motion-formulas
description: Script procedural motion graphics in NewScene using native grids, Multiply, Increment, stagger, morphs, waves, nested tunnels, lens exits, and camera handoffs. Use for kinetic abstract geometry, reusable motion recipes, or golden-ratio and fractal experiments. Separate project-tested patterns from proposed experiments.
---

# NewScene motion formulas

Author through the editor scripting API. Discover current schemas; inspect owners, points, effects, and timing. Preserve unrelated work. Generate native layers and keyframes; do not invent shader equations or custom SVG assets.

## Notation

Use zero-based occupied-cell index `i`, count `N`, frame rate `F`, frame `f`, seconds `t=f/F`, tempo `B`. Set `u=clamp((f-f0)/(f1-f0),0,1)` and `L(a,b,u)=a+(b-a)E(u)`. Use native easing `E`; use radians for trigonometry and degrees for editor rotation. Let `R(θ)` be a 2D rotation matrix; `P(s)` an outline point at normalized distance `s`.

## Patterns used in the motion study

Treat these as reusable mathematical descriptions of the authored patterns, not reverse-engineered renderer code. Numeric examples below come from the inspected wave, grid, tunnel, portal, and lens recipes.

| Formula name | Formula / equation | Short description |
|---|---|---|
| Beat clock | `f(b)=round(f0+b·60F/B)` | Land on beats; derive frames from absolute beats to avoid rounding drift. |
| Stagger | `dᵢ=round(S·i/max(1,N−1))` | Start one after another; spread entrances across `S` frames. |
| Cascade clock | `τᵢ=(f−dᵢ)/F` | Repeat the same motion later; use each child's entry clock. |
| Shared clock | `τ=f/F` | Move together; stagger visibility but synchronize motion. |
| Increment | `vᵢ(t)=v(t)+iΔ` | Step each copy; fan cards with constant angle differences. |
| Multiply | `vᵢ(t)=v(t)mⁱ` | Grow each copy; `m>1` grows, `0<m<1` shrinks. |
| Alternating Multiply | `vᵢ(t)=v(t)(−m)ⁱ` | Spin opposite; alternate direction as magnitude grows. Used `m=1.025`. |
| Grid coordinates | `c=i mod C; r=floor(i/C)` | Arrange rows and columns; let the grid own placement. |
| Grid–orbit–grid | `pᵢ=L(gᵢ,P(fract(i/N+νt)),u)` | Gather into an orbit, then return; `ν` is cycles/second. Use native Layout and Along Path for actual interpolation. |
| Morph sequence | `G(t)=NativeMorph(Ga,Gb,E(u))` | Change the outline; cycle ellipse, star, rectangle, triangle on beat keys. |
| Pulse | `s(t)=L(sa,sb,u)` on alternating keys | Breathe bigger and smaller; reuse one envelope across a group. |
| Squash and stretch | `sx=s0−Ax·sinψ; sy=s0+Ay·sinψ` | Stretch tall, then wide; opposing axes feel elastic, without preserving area. |
| Traveling wave | `ψ=ω(t−dᵢ/F)+φr; y=A·sinψ` | Send a wave across rows; combine row phase and child stagger. |
| Phase ribbons | `vᵣ(t)=v0+A·sin(ωt+φr)` | Let rows chase each other; reduce phase differences to synchronize. |
| Counter-rotation | `θ±(t)=θ0±Θ(t)` | Turn two groups against each other; create interlocking fans. |
| Nested transforms | `pworld=Tparent·Tchild·plocal` | Move a whole machine; combine outer and inner grid motion. Verify native transform order. |
| Exponential tunnel | `Wi=W0qⁱ; Hi=H0qⁱ; θi=Θ(t)+iΔ` | Stack smaller frames inward; used `q=.84`, `Δ=7°`. |
| Recursive portal | `si=s(t)qⁱ; bi=b(t)aⁱ; θi=Θ(t)+iΔ` | Bend deeper layers less; used 24 layers, `q=.83`, `a=.72`, `Δ=9°`. |
| Center compensation | `tx=W(1−sx)/2; ty=H(1−sy)/2` | Keep the center still when scaling from top-left; add cell-center correction if needed. |
| Clock compensation | `flocal=max(0,fscene−dᵢ)` | Land child keys together; convert scene events into child-local frames. |
| Pinched portal | `aspect=(W·sx)/(H·sy)` | Squeeze toward a vertex; 1300×850 with `sx=2.6, sy=.10` gives about 40:1, plus pointed morphs. |
| Kinetic wipe | `p(t)=L(poutside,pcover,u)` | Sweep a new background color across the frame; keep an opaque base. |
| Lens stretch exit | `k=L(0,−12,u); W=L(W0,W1,u); H=L(H0,H1,u)` | Stretch across the screen; combine negative Lens Warp, size expansion, and recentering. |
| Pull across a cut | `zout(tc)=zin(tc)` | Continue through the cut; match effective zoom and center, then finish the incoming pull. |

## Copyable values

- **Grid energy:** Multiply scale by `1.025ⁱ`, rotation by `(−1.025)ⁱ`, horizontal shift by `(−1.04)ⁱ`. Use child clocks. Key X/Y scale through `(75,110) → (130,50) → (50,140) → (145,65)` percent; rotate through `0 → 90 → 180 → 360°`; continue pulses.
- **Wave rows:** `φr=rπ/2`, `sx=(85−18sinψ)·1.055ⁱ`, `sy=(100+62sinψ)·1.055ⁱ` percent; `y=44sinψ`, `θ=28cosψ` degrees. Derive frequency from the project beat.
- **Portal pinch:** exaggerate bend to 800 px, spin the owner through multiple turns, morph ellipse → droplet → ellipse → triangle → ellipse, then restore circular proportions.
- **Lens exit:** warp `0,−2,−8,−12`; final square `200×200 → 500×140 → 2200×800 → 5600×2500`. Match its final lime fill to the incoming background. These are scene-specific examples, not universal defaults.

## Next experiments — not yet validated in NewScene

Set `φ=(1+√5)/2`, `α=2π/φ²`, `θ=2πt/T`. Use supported native layouts/transforms; sample deterministic keys only where no native mechanism exists.

| Formula name | Formula / equation | Short description |
|---|---|---|
| Golden tunnel | `si=φ^(−i); θi=iα+ωt` | Shrink by golden ratio; twist nested triangles into a portal. |
| Golden spiral | `r(θ)=r0·φ^(2θ/π); p=c+r(cosθ,sinθ)` | Grow each quarter-turn by φ; send shapes along an expanding spiral. |
| Sunflower layout | `ri=a√i; θi=iα` | Spread like seeds; bloom a grid into a golden-angle disk. |
| Rose orbit | `r=Rcos(kθ); p=c+r(cosθ,sinθ)` | Draw flower loops; orbit shapes through petal patterns. |
| Lissajous weave | `x=A sin(mθ+δ); y=B sin(nθ)` | Weave crossing loops; try integer frequencies `m:n=3:2` for a closing cycle. |
| Radial ripple | `vᵢ=v0+A sin(ωt−κ·distance(pi,c))` | Send rings outward; use distance for phase or entrance delay. |
| Recursive triangle | `pj=(p+vj)/2; sj=s/2`, recurse over 3 vertices | Split into three; build a finite Sierpiński-like triangle cascade. |
| Golden branching | `pj=p+sR(θ)vj; sj=s/φ; θj=θ±β` | Grow two branches; nest shrinking shapes into a finite tree. |
| Kaleidoscope | `pj=c+R(2πj/K)·diag((−1)ʲ,1)·p(t)` | Mirror around a center; use even `K` for alternating reflected sectors. |
| Cascaded envelope | `vᵢ(t)=v0+A mⁱ h(t−dᵢ/F)` | Pass one pulse onward; let `h` drive scale, warp, rotation, and opacity at different phases. |

## Combine recipes

- **Golden bloom:** grid → sunflower layout → radial stagger → alternating spin → golden tunnel.
- **Fractal heartbeat:** three-way triangle recursion → depth delay `dℓ=ℓΔf` → scale pulse → reverse collapse.
- **Living kaleidoscope:** rose orbit → mirrored sectors → shape morph → phase-shifted squash/stretch.
- **Portal relay:** exponential tunnel → traveling bend → pointed pinch → lens expansion → matching-color cut during pull-back.

## Editor rules learned

- Use Increment **or** Multiply per field. Zero times a multiplier stays zero. Clamp field limits; avoid accidental negative scale when only alternating rotation is intended.
- Use depth-first occupied-cell order. `offsetAnimation:true` uses child clocks; `false` uses the shared grid clock. Grid stagger controls starts in both modes.
- Keep units explicit: grid Scale is percent (`100` neutral); per-layer Scale is ratio (`1` neutral). Shared point times are seconds; point operations use layer-local frames.
- Use scale ratios in geometry equations. For a shared event before child entry, sample the entry pose and omit earlier events; do not collapse multiple different keys onto local frame zero.
- For `D` frames, use visible samples `0…D−1`; an end boundary at `D` is not a rendered frame. Budget native operations, not scalar values: one Translate point can contain both X and Y.
- Inspect ownership before moving children. Use Translate, not Position. Resend the complete saved configuration when replacing All layers Adjust. Preserve native entry/exit presets unless deliberately replacing an exit.
- Apply center compensation only when the observed transform needs it. Add `(commonCenter−cellCenter)` for cell offsets; use `(baseSize−newSize)/2` for size animation.
- Prefer native morphs and Along Path. Sample Layout/morph endpoints: an earlier experiment showed snapping near a handoff. Do not assume more keys fix renderer behavior.
- Treat Lens Warp as a native black box. Shared grid warp saved without visible distortion in this project; direct layer keys worked. Extreme negative values did not monotonically enlarge the shape; expansion supplied the full-frame stretch. Recheck current behavior before copying this workaround.
- Match pose at camera handoffs; match velocity when feasible. Our cross-cut recipe matched effective zoom using outgoing camera zoom and incoming group scale; still previews did not verify continuous motion.
- Bound recursion: `N=b^D` leaves, or `(b^(D+1)−1)/(b−1)` nodes including parents. Start shallow; reuse groups/shared effects; inspect current batch limits. Finite fractal-like layers are feasible experiments, not an infinite renderer.
- Validate unfamiliar operations, preview changed poses and cut-adjacent frames, confirm saving, then release. Stills do not certify playback, audio sync, or export fidelity.
