API Overview¶
A compact summary of the library. Each section links to the tutorial chapter that explains it with examples.
Setup and the clock¶
Keyed.init(this), called insetup(), hooks into Processing so animations follow real time. It returns the default timeline, used by every value that isn't given a timeline.- Global settings, set before creating timelines:
Keyed.setUnit(Keyed.SECOND | Keyed.FRAME)measures times in seconds or frames.Keyed.setFrameRate(fps)sets the frame rate used to convert between frames and seconds.Keyed.sync(bool):truefollows real time;falseadvances exactly one frame perdraw(), for repeatable exports.Keyed.autoplay(bool)turns automatic advancing on or off.
See Getting Started and Timelines.
Animated values: Keyed<A>¶
- Built-in types:
Keyed.ofFloat(),ofInt(),ofColor(),ofBoolean(),ofString(),ofPVector(), each optionally with a default value used while there are no keys. - Shorthand:
Keyed.of(value)picks the type from afloat,PVector,Stringorbooleanvalue. - Any type:
new Keyed<>(lerp, default), orKeyed.of(obj)forLerpabletypes. - Keys:
key(t, value),removeKey(...),clearKeys(),keys(). - Reading:
value()is the value now;value(t)the value at any time. echo(samples, delay)returns the value at several past (or future) times, e.g. for motion trails.setTimeline(tm)attaches the value to a timeline other than the default.
See Getting Started.
Keys, pins and easing¶
Key.at(t)is a key with its own easing:- Influence, After Effects style:
setEasing(1 / 3f),setEasingIn(...),setEasingOut(...). - Curves:
setEasing(Easing.CUBIC_IN_OUT)and otherQUAD/CUBIC/QUART/QUINTpresets,SMOOTHSTEP,HOLD. hold()keeps the value until the next key.
- Influence, After Effects style:
- Custom easing:
Easing.cubicBezier(...),quadraticBezier(...),smoothstep(...),steps(n),powerIn/powerOut/powerInOut(p), or any lambdad -> .... Pin.at(t)is a point in time shared by keys and markers.pin.to(t)moves all of them;addListener()reports moves.
Timeline¶
- Creating:
new Timeline(), thenvalue.setTimeline(tm). Several timelines are independent clocks. - Duration:
setDuration(d)loops;setDuration(d, false)plays once.loop(bool),isLooping(),isFinished(). - Playback:
play(bool),isPlaying(),setSpeed(s)(negative plays backwards),to(t)to jump,to(t, true)to jump and fire markers on the way,step()to advance by hand. - Timing:
t()is the current time,t(offset)a time relative to it.sync(bool)andsetFixedStep(dt)for exact stepping. dispose()stops a timeline you no longer need.
See Timelines.
Events¶
- Markers:
addMarker([name,] t or pin, callback),marker(name),markers(),removeMarker(m). - Listeners:
onLoop(callback),onFinish(callback),removeListener(callback). - Markers fire on playback in either direction, also when a loop wraps around. A plain
to(t)fires nothing.
See Events.
Binding¶
Keyed.bind(obj, "field")writes the animated value into a float field before everydraw().Keyed.bind(lerp, default, setter)orkeyed.bind(setter)passes it to a setter.unbind()stops updating;apply()writes the value immediately.
See Binding.
Tweens and paths¶
Tween<T>is a value as a function ofdfrom 0 to 1. A key can follow a tween instead of a fixed value;tween.at(d)fixes a key to one position.map(f)converts a tween's values;x()andy()give one coordinate of a path.- Paths:
QuadraticBezier,CubicBezier(both at constant speed),Spline(likecurveVertex(), withsetTightness()), andCurveto chain them withadd(). slice(t0, t1)is part of a path; swapping the ends reverses it.
See Paths.
Effects¶
Added with addEffect(...), applied in the order added.
- Value effects:
Wiggle,Orbit,GridSnap. - Time effects:
Spring,Lag,StopMotion. - Shortcuts for
PVectors:Effect.wiggle(...),orbit(...),gridSnap(...),spring(...),lag(...). - Custom: lambdas
(value, t) -> ...asEffect, or(source, t) -> ...asTimeEffect.
See Effects.
Lerps and types¶
- Lerps:
FloatLerp,IntLerp,PVectorLerp,ColorLerp,AngleLerp,StringLerp,BooleanLerp,StepLerp, or any lambda(a, b, d) -> .... Lerpable<T>: a type that blends itself.Quaternion: 3D rotation without gimbal lock.ShapeMorph: morphs between polygons with different point counts, in 2D or 3D.
See Types.
Composition¶
- Subclass
Compositionfor a reusable animation on its own one-shot timeline. Key times are local. add(keyed),play(),isFinished(),dispose(),timeline().
See Composition.