Class Lemniscate

An animautomaton that draws along a path resembling an infinity symbol.

Hierarchy (view full)

Constructors

Properties

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.

arcs: number

The number of individual shapes to draw.

arcWidth: number

Width of the primary arc (in pixels).

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.

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

geometries: LemniscateGeometry[]

An array of geometric information objects where geometries[i] is the info for the ith arc.

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

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)}

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

Type declaration

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

      Returns void

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

Type declaration

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

      Parameters

      • ops: Partial<LemniscateOps>

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

      Returns void

radius: number

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

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.

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

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 head (starting point) at all times.

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

Transformation to apply to this animation's progress.

Default: sinusoidal

xOff: number

The distance from the origin to the centre of each path circle along the x-axis.

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 the necessary positions for the ith arc in the animation.

    Parameters

    • i: number

    Returns ArcPoints

    outer_lead, mid_lead, inner_lead, outer_tail, mid_tail, inner_tail

  • 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

  • Calculates helpful geomtric information for rendering the lemniscate shape

    Parameters

    • radius: number

      Radius of both "circles" in the shape

    • xOff: number

      Distance from midpoint to the centre of each circle

    Returns LemniscateGeometry

  • Parameters

    • order:
          | "lead"
          | "tail"
          | "outer-mid"
          | "inner-mid"
          | "contained"
    • points: ArcPoints
    • arc_i: number

    Returns void

  • Parameters

    • order:
          | "lead"
          | "tail"
          | "outer-mid"
          | "inner-mid"
          | "contained"
    • points: ArcPoints
    • arc_i: number

    Returns void

  • Parameters

    • order:
          | "lead"
          | "tail"
          | "outer-mid"
          | "inner-mid"
          | "contained"
    • points: ArcPoints
    • arc_i: number

    Returns void

  • Parameters

    • order:
          | "lead"
          | "tail"
          | "outer-mid"
          | "inner-mid"
          | "contained"
    • points: ArcPoints
    • arc_i: number

    Returns void

  • Parameters

    • order:
          | "lead"
          | "tail"
          | "outer-mid"
          | "inner-mid"
          | "contained"
    • points: ArcPoints
    • arc_i: number

    Returns void

  • Parameters

    • order:
          | "lead"
          | "tail"
          | "outer-mid"
          | "inner-mid"
          | "contained"
    • points: ArcPoints
    • arc_i: number

    Returns void

  • Parameters

    • order:
          | "lead"
          | "tail"
          | "outer-mid"
          | "inner-mid"
          | "contained"
    • points: ArcPoints
    • arc_i: number

    Returns void

  • Parameters

    • order:
          | "lead"
          | "tail"
          | "outer-mid"
          | "inner-mid"
          | "contained"
    • points: ArcPoints
    • arc_i: number

    Returns void

  • Parameters

    • section: number
    • order:
          | "lead"
          | "tail"
          | "outer-mid"
          | "inner-mid"
          | "contained"
    • points: ArcPoints
    • arc_i: number

    Returns void

  • 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.

  • Parameters

    • prog: number

      A number between 0 and 1.

    • arc_i: number

      The index of the arc whose geometry we're interested in.

    Returns number

    The animation section corresponding to the progress value, or -1 on failure.

  • Given a progress value, calculates the useful points that far along the animation's path for the ith arc.

    Parameters

    • prog: number

      A number between 0 and 1 representing the position along the path to get.

    • i: number

      The index of the arc.

    Returns ArcEndPoint

    Outer, centre, and inner points for the given progress

  • 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