@kayahr/wastelib
    Preparing search index...

    Class Ending

    Contains the base frame of the ending animation but also provides methods to access the animation information. To simply play the animation it is recommended to use the [[EndingPlayer]] class.

    Hierarchy (View Summary)

    Implements

    Index

    Properties

    data: Uint8Array

    The image data.

    height: number

    The image height in pixels.

    width: number

    The image width in pixels.

    Methods

    • Creates and returns an animation player for this animation. The actual drawing is done by the specified callback which is called for each frame and receives the image to render.

      Parameters

      • onDraw: (frame: BaseImage) => void

        Callback to call on each frame update. This callback is responsible for actually showing the animation frame to the user.

      Returns EndingPlayer

      The created animation player. You have to call the start() method on it to start the animation.

    • Draws the image onto the given rendering context.

      Parameters

      • ctx: CanvasRenderingContext2D

        The rendering context to draw the image to.

      • x: number = 0

        Optional horizontal target position. Defaults to 0.

      • y: number = 0

        Optional vertical target position. Defaults to 0.

      Returns void

    • Returns the RGBA color at the specified position.

      Parameters

      • x: number

        The horizontal pixel position.

      • y: number

        The vertical pixel position.

      Returns number

      The RGBA color at the specified position.

    • Returns a copy of the image data. Each byte contains two 4-bit colors.

      Returns Uint8Array

      The image data.

    • Returns the number of animation updates.

      Returns number

      The number of animation updates.

    • Creates and returns a new canvas containing the image.

      Returns HTMLCanvasElement

      The created canvas.

    • Creates and returns an image data URL.

      Parameters

      • Optionaltype: string

        Optional image mime type. Defaults to image/png.

      • Optionalquality: number

        Optional quality parameter for encoder. For image/jpeg this is the image quality between 0 and 1 with a default value of 0.92.

      Returns string

      The created data URL.

    • Creates and returns a HTML image.

      Parameters

      • Optionaltype: string

        Optional image mime type. Defaults to image/png.

      • Optionalquality: number

        Optional quality parameter for encoder. For image/jpeg this is the image quality between 0 and 1 with a default value of 0.92.

      Returns HTMLImageElement

      The created HTML image.

    • Parses a end animation from the given array and returns it.

      Parameters

      • array: Uint8Array

        The array containing the two encoded MSQ blocks with the base frame and animation data.

      Returns Ending

      The parsed end animation.

    • Reads the end animation from the given blob and returns it.

      Parameters

      • blob: Blob

        The END.CPA blob.

      Returns Promise<Ending>

      The read end animation.