@kayahr/wastelib
    Preparing search index...

    Class Tile

    Container for a single tile.

    Hierarchy (View Summary)

    Index

    Properties

    data: Uint8Array

    The image data.

    height: number

    The image height in pixels.

    width: number

    The image width in pixels.

    Methods

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

    • 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 tile from the given array buffer.

      Parameters

      • array: Uint8Array

        The array buffer containing the image data.

      • offset: number = 0

        Optional data offset. Defaults to 0.

      Returns Tile

      The parsed tile.