Class Antiquum

An animautomaton based on the traditional rotating/spinning arc loader.

Hierarchy (view full)

Constructors

Properties

arcAnchor: "inner" | "centre" | "outer"

Determines where arcs of differing width will align.

Default: centre

arcDelay: number

A value between 0 and 1 indicating what percentage behind in the loop each successive arc will be.

Only has an effect with multiple arcs.

Default: 0.1

arcs: number

The number of individual shapes to draw.

Default: 1

arcWidth: number

Width of the primary arc (in pixels).

Default: 10

arcWidthDelta: number

Only has an effect with multiple arcs. Each arc will be this much (proportional to primary arcWidth) narrower than the previous.

Can be set to a negative value to make successive arcs larger.

Default: 0.02 (>0 to avoid aliasing)

backgroundColour: null | string

If not null: the canvas will be painted this colour.

Default: null

colours: string[]

An array of 7-character hex code colour strings (e.g. ["#ffffff"]). (Must be 7 characters for opacity to work properly.)

currIteration: number

The current iteration of this animation.

Default: 0

currProgress: number

A number between 0 and 1 representing the animation's progress through its loop THIS frame.

Default: 0

customTimingFunction: ((offset?: number) => number)

This function will be called iff timingFunction = "custom"

Custom timing functions must take in an offset to apply to currProgress, and return a value between 0 and 1.

cycleDuration_ms: number

Number of milliseconds this animation's loop will take. Lower = faster.

Default: 1000

drawStyle: "fill" | "stroke"

Represents which Context2D drawing function to call.

Default: fill

fps: number

Number of requested renders per second (not guaranteed!).

Default: 60

innerBorder: null | Border

If not null, defines the style of the inner border.

Default: null

lastMutationTimestamp: number

High resolution timestamp (ms) of when this animation was last mutated.

Default: 0

lastProgress: number

A number between 0 and 1 representing the animation's progress through its loop LAST frame.

Default: 0

leadCap: null | "flat" | "rounded"

Determines the lead line cap appearance. Overrides lineCap if not null.

Default: null

lineCap: "flat" | "rounded"

Determines the lead AND tail line cap appearance. Lower priority than leadCap and tailCap.

Default: rounded

nIterations: number

This animation will pause after this many loops.

Default: Infinity (i.e. animation continues forever)

opacity: number

A number between 0 and 1.

The base transparcency to apply to colours when drawing.

Default: 1

opacityDelta: number

Each differentiable section will have this much less opacity than the previous section (minimum 0).

Default: 0

origin: Vector2

The (x,y) value of the geometric centre of the canvas.

Default: {x: Math.floor(canvas.width / 2), y: Math.floor(canvas.height / 2)}

outerBorder: null | Border

If not null, defines the style of the outer border.

Default: null

parentDraw: (() => void) = ...

Type declaration

    • (): void
    • Uses this.context to draw the current frame of the animation, as determined by the current configuration and this.currProgress.

      Called by this.animate().

      Returns void

parentSetConfig: ((ops: Partial<AntiquumOps>) => void) = ...

Type declaration

    • (ops): void
    • Sets one or more configurable properties of this Animautomaton.

      Parameters

      • ops: Partial<AntiquumOps>

        An object containing one or more valid {AntiquumOps} properties.

      Returns void

radius: number

Radius of the circle that the centre of the arcs will travel along, in pixels.

Default: 75% of minimum canvas dimension

radiusDelta: number

Only has an effect with multiple arcs. Each arc will travel along a path with radius this much less (proportional to primary radius).

Can be set to a negative value to make successive arcs travel along a path with greater radius.

Default: 0

rest: number

A number between 0 and 1.

This animation will be still in its starting position for this proportion of its duration.

Default: 0

rotations: number

The number of rotations the circular path will make in a single loop as the arcs travel around it.

Note: This can be set to a non-integer value (e.g. 1.5) but this will result in the animation not necessarily repeating exactly every loop, which usually will not matter but may interfere with certain API uses.

Default: 1

tailCap: null | "flat" | "rounded"

Determines the tail line cap appearance. Overrides lineCap if not null.

Default: null

tailDelay: number

A value between 0 and 1 indicating what percentage behind in the loop the arc's tail (endpoint) will be compared to its lead (starting point) at all times.

Default: 0.1

timingFunction:
    | "linear"
    | "sinusoidal"
    | "quadratic"
    | "cubic"
    | "custom"

Transformation to apply to this animation's progress.

Default: sinusoidal

trackColour: null | string

If not null, the ring that the arcs travel along will have this background colour.

Default: null

Methods

  • This function is called every animation frame & decides whether or not to draw a new frame of this animation, and also whether or not to call mutate().

    Returns void

  • Calculates values used for future geometric calculations.

    Parameters

    • arc_i: number
    • arcWidthDiff: number

    Returns Offsets

  • Calculates geometric information used for drawing an arc shape.

    Parameters

    • leadProgress: number
    • tailProgress: number
    • offsets: Offsets
    • arcWidthDiff: number

    Returns Positions

  • Sets both context.strokeStyle and context.fillStyle with appropriate opacity.

    Parameters

    • offset: number

      The index of the colour in this.colours (wraps around).

    Returns void

  • Uses this.context to draw the current frame of the animation, as determined by the current configuration and this.currProgress.

    Called by this.animate().

    Returns void

  • Draws the borders of the area the arcs travel along, iff borders are not null.

    Returns void

  • Draws a middle section of an arc shape. Draws the outer line if {hasDrawnLead} is false, and the inner line otherwise.

    Parameters

    Returns void

  • Draws the background ring / track that the arcs travel over iff this.trackColour is not null.

    Returns void

  • Returns number

    The number of rotations + partial rotations this animation has performed.

  • Parameters

    • Optionaloffset: number

      An amount to either add or subtract from the base progress before transformation.

    Returns number

    A value between 0 and 1 representing the animation's progress through its loop, transformed according to this.timingFunction.

  • Moves the animation immediately a certain number of frames.

    Parameters

    • frames: number

      Number of frames to seek (negative = rewind, 0 = re-render current frame)

    Returns void