Class Utils

Constructors

Methods

  • Add alpha component to a RGB string

    Parameters

    • str: string
    • alpha: string

    Returns string

  • Return int value of an hex color

    Parameters

    • str: string
    • Optional prefix: string

    Returns number

  • Revert RGBA components

    Parameters

    • rgba: string

    Returns string

    abgr string

  • Convert an hexadecimal string to an array of hex byte

    Parameters

    • hex: string

    Returns string[]

  • Fetch image from server with an index used to determine position

    Parameters

    • images: string[]

    Returns Promise<ImageBitmap[]>

  • Convert an array of ImageBitmap objects to raw RGBA pixel arrays. Useful for preparing noise or animation frames for GPU renderers.

    Parameters

    • bitmaps: ImageBitmap[]
    • width: number
    • height: number

    Returns Uint8ClampedArray[]

    Example

    const bitmaps = await Utils.loadImagesOrdered(urls)
    const frames = Utils.bitmapsToPixelData(bitmaps, layer.width, layer.height)
  • Fetch image from server with an index used to determine position

    Parameters

    • images: string[]

    Returns Promise<ImageBitmap[]>