Dynamic Token Ring Manager.

Constructors

  • A TokenRing is constructed by providing a reference to a Token object.

    Parameters

    • token: Token

    Returns TokenRing

Properties

ringName: string
bkgName: string
ringUVs: Float32Array
bkgUVs: Float32Array
ringColorLittleEndian: number = 0xFFFFFF
bkgColorLittleEndian: number = 0xFFFFFF
defaultRingColorLittleEndian: number = null
defaultBackgroundColorLittleEndian: number = null
effects: number = 0
scaleCorrection: number = 1
scaleAdjustmentX: number = 1
scaleAdjustmentY: number = 1
subjectScaleAdjustment: number = 1
textureScaleAdjustment: number = 1
colorBand: RingColorBand
#token: WeakRef<Token>

Weak reference to the token being animated.

effects: Readonly<Record<string, number>> = ...

The effects which could be applied to a token ring (using bitwise operations).

baseTexture: BaseTexture

Token Rings sprite sheet base texture.

texturesData: Record<string, {
    UVs: Float32Array;
    center: {
        x: number;
        y: number;
    };
}>

Rings and background textures UVs and center offset.

Type declaration

  • UVs: Float32Array
  • center: {
        x: number;
        y: number;
    }
    • x: number
    • y: number
tokenRingSamplerShader: any

The token ring shader class definition.

#ringData: {
    ringName: string;
    bkgName: string;
    colorBand: RingColorBand;
    gridTarget: number;
    defaultRingColorLittleEndian: number;
    defaultBackgroundColorLittleEndian: number;
    subjectScaleAdjustment: number;
}[]

Ring data with their ring name, background name and their grid dimension target.

Type declaration

  • ringName: string
  • bkgName: string
  • colorBand: RingColorBand
  • gridTarget: number
  • defaultRingColorLittleEndian: number
  • defaultBackgroundColorLittleEndian: number
  • subjectScaleAdjustment: number
#defaultRingThickness: number = 0.1269848

Default ring thickness in normalized space.

#defaultSubjectThickness: number = 0.6666666

Default ring subject thickness in normalized space.

Accessors

  • get token(): any
  • Reference to the token that should be animated.

    Returns any

  • get initialized(): boolean
  • Is the token rings framework enabled? Will be null if the system hasn't initialized yet.

    Returns boolean

Methods

  • Configure the sprite mesh.

    Parameters

    • Optional mesh: PrimarySpriteMesh

      The mesh to which TokenRing functionality is configured.

    Returns void

  • Clear configuration pertaining to token ring from the mesh.

    Returns void

  • Configure token ring size.

    Returns void

  • Configure the token ring visuals properties.

    Returns void

  • Flash the ring briefly with a certain color.

    Parameters

    • color: typeof Color

      Color to flash.

    • animationOptions: CanvasAnimationOptions = {}

      Options to customize the animation.

    Returns Promise<boolean | void>

  • Configure dynamic token ring subject texture.

    Parameters

    • mesh: PrimarySpriteMesh

      The mesh being configured

    Returns void

  • Initialize the Token Rings system, registering the batch plugin and patching PrimaryCanvasGroup#addToken.

    Returns void

  • Create texture UVs for each asset into the token rings sprite sheet.

    Returns void

  • Get the UVs array for a given texture name and scale correction.

    Parameters

    • name: string

      Name of the texture we want to get UVs.

    • Optional scaleCorrection: number = 1

      The scale correction applied to UVs.

    Returns Float32Array

  • Get ring and background names for a given size.

    Parameters

    • size: number

      The size to match (grid size dimension)

    Returns {
        bkgName: string;
        ringName: string;
        colorBand: RingColorBand;
    }

  • Create an easing function that spikes in the center. Ideal duration is around 1600ms.

    Parameters

    • Optional spikePct: number = 0.5

      Position on [0,1] where the spike occurs.

    Returns Function

  • Easing function that produces two peaks before returning to the original value. Ideal duration is around 500ms.

    Parameters

    • pt: number

      The proportional animation timing on [0,1].

    Returns number

    The eased animation progress on [0,1].