interface RVG · Core

RvgClock

interface RvgClock

The animation clock shared by all graphics, available as VisQuill.clock.

In real time (the default), animations follow the browser's frames. In manual mode, time stops and moves only with RvgClock.advance or RvgClock.advanceFrames, which run the animation frames and update the DOM before they return. This allows capturing an animation frame by frame, for example for a video. When switching modes, the time continues where it was; running animations go on without a jump.

Example

VisQuill.clock.useManual();
Animate.point.eased(point, target, 1000);
for (let i = 0; i < 60; i++) {
    VisQuill.clock.advanceFrames(1, 60);  // one frame at 60 fps
    await captureFrame(svg);              // your own capture code
}
VisQuill.clock.useRealtime();

Properties

manualreadonly

readonly manual: boolean

True in manual mode.

nowreadonly

readonly now: number

The current time in milliseconds.

Methods

advance

advance(ms: number): void

Moves the time forward by ms milliseconds and runs one frame at the new time: animations, reactions, and DOM updates. Throws when the clock is not in manual mode.

advanceFrames

advanceFrames(count: number, fps: number): void

Runs count frames at fps frames per second, each with RvgClock.advance(1000 / fps).

useManual

useManual(): void

Switches to manual mode: time stops and moves only with advance and advanceFrames.

useRealtime

useRealtime(): void

Switches back to real time (the browser's frames); waiting animations continue from the current time.