ObjectBatch
Many objects animated on the same keys as one run (a Batch): hundreds of sprites, a chart's points,
a grid of meshes that move together. wardic.batch(objects) makes one; animate(batch, target) moves
every member, each key's value a number, two stops (its first and its target), or a function of a
member's index and the count; animate(batch.at(i), target) moves member i. A new target turns each
member toward it at the speed it has, for a fraction of what an animation per object costs.
- Its keys are fixed by its first
animate(orkeyswhen it's made). Each member starts from its own values for them, numbers each. - Its members are reached through it: an object of a Batch given to
animateitself is an error.
const swarm = wardic.batch(sprites)
wardic.animate(swarm, { x: (i) => i * 12, y: [0, 40] }, { type: "spring", delay: stagger(0.01) })
wardic.animate(swarm.at(3), { y: 0 })Interfaces
Context
What a runtime gives its Batches: its fork, and its Environment's Positional keys and Default transitions.
Properties
defaultTransition
readonly defaultTransition: DefaultTransition;positionalKeys
readonly positionalKeys: PositionalKeys;read
readonly read: (subject, key) => unknown;How it reads a member's key before the Batch moves it: plain objects' read, the property.
Parameters
subject
object
key
string
Returns
unknown
runFork
readonly runFork: <A, E>(effect) => Fiber<A, E>;Type Parameters
A
A
E
E
Parameters
effect
Effect<A, E, FrameLoop>
Returns
Fiber<A, E>
unitScale
readonly unitScale: Rule;The Environment's unit scale: each key's units for its Batches' rest thresholds.
writer
readonly writer: Writer<object>;How the Environment draws a Batch's members: plain objects' writer, or another Environment's.
Member
A member's handle: animate and a sequence's Segment move member i alone.
Type Parameters
T
T extends object
Key
Key extends string = NumberKey<T>
Properties
batch
readonly batch: ObjectBatch<T, Key>;i
readonly i: number;ObjectBatch
A Batch of objects T.
Type Parameters
T
T extends object
Key
Key extends string = NumberKey<T>
Properties
at
readonly at: (i) => Member<T, Key>;Member i's handle, for animate and a sequence's Segment.
Parameters
i
number
Returns
Member<T, Key>
get
readonly get: (i, key) => number;Member i's value for key now: as drawn, once the Batch has moved; its own before.
Parameters
i
number
key
Key
Returns
number
members
readonly members: readonly T[];Its members, in order.
velocity
readonly velocity: (i, key) => number;Member i's velocity for key now, per second: 0 before the Batch has moved.
Parameters
i
number
key
Key
Returns
number
Options
wardic.batch's options.
Type Parameters
T
T
Key
Key extends string = NumberKey<T>
Properties
keys?
readonly keys?: readonly Key[];Its keys, fixed now: else its first animate's, or its first Segment's.
Type Aliases
NumberKey
type NumberKey<T> = { readonly [K in keyof T]-?: T[K] extends number ? K : never }[keyof T] & string;A key of T a Batch animates: one whose value is a number.
Type Parameters
T
T
SegmentValue
type SegmentValue =
| number
| null
| ReadonlyArray<number | null>
| ((i, n) => number | null | ReadonlyArray<number | null>);A Batch's key in a sequence's Segment of it: a number, null for where it is, stops of them, or a function giving them.
Stop
type Stop = number | ((i, n) => number);A stop of a Batch's animate: a number for every member, or a function of a member's index and the count.
Target
type Target<T, Key> = { readonly [K in Key]?: Stop | readonly [Stop, Stop] | ((i: number, n: number) => number | readonly [number, number]) };A Batch's targets for an animate call: each key a stop, two (its first and its target), or a function giving them.
Type Parameters
T
T
Key
Key extends string = NumberKey<T>
Variables
writer
const writer: Batch.Writer<object>;The property writer for a Batch's keys: each member's values onto its properties, by name.
Functions
entryOf()
function entryOf(given): any;The Batch or member handle given is, for animate: undefined for anything else.
Parameters
given
unknown
Returns
any
make()
function make<T>(
context,
objects,
options?
): ObjectBatch<T>;A Batch of objects for a runtime, its keys options.keys, else its first call's.
Type Parameters
T
T extends object
Parameters
context
objects
readonly T[]
options?
Options<T> = {}
Returns
ObjectBatch<T>
memberOf()
function memberOf(object): number | undefined;object's member number in a Batch, or undefined when it's no Batch's.
Parameters
object
object
Returns
number | undefined
read()
function read(subject, key): unknown;A plain object's key, as a Batch reads it before moving it: the property.
Parameters
subject
object
key
string
Returns
unknown