Blockbench Reference Docs
    Preparing search index...

    An Int Matrix holds an int (unsigned 8 bit) for each pixel in a matrix, via array. The override property can be used to set an override value for the entire area. This is used for texture selections.

    Index

    Constructors

    Properties

    array: Int8Array<ArrayBufferLike>
    height: number
    is_custom: boolean

    True if there is a custom selection

    override: boolean

    The override can be set to true to indicate that the whole texture is selected, or false, which indicates that nothing is selected. Null indicates a custom selection

    width: number

    Methods

    • Test whether painting is allowed at a specific pixel

      Parameters

      • x: number

        X coordinate

      • y: number

        Y coordinate

      Returns number | boolean

      Boolean or value of the pixel

    • Change the size of the matrix. Unless using overrides, the selection gets lost.

      Parameters

      • width: number
      • height: number

      Returns void

      Whether the size had to be changed

    • Run a method on each pixel, whether selected or not

      Parameters

      • callback: (x: number, y: number, value: number, index: number) => void

        Function to run per pixel

      Returns void

    • Get the value at the specified pixel

      Parameters

      • x: number

        X coordinate

      • y: number

        Y coordinate

      Returns number | boolean

      The value of the targeted pixel

    • Return the smallest possible rectangle that contains all of the selection

      Parameters

      • respect_empty: boolean

        If true, if there is no selection, the bounding box will still cover the entire area

      Returns Rectangle

    • Get the value at the specified pixel directly without override and bounds check

      Parameters

      • x: number

        X coordinate

      • y: number

        Y coordinate

      Returns number

    • Mask the provided canvas using the selection

      Parameters

      • ctx: CanvasRenderingContext2D

        Canvas 2D context

      • offset: ArrayVector2

        Position offset of the canvas, e. g. when using a layer

      Returns void

    • Set the value at a specified pixel

      Parameters

      • x: number

        X coordinate

      • y: number

        Y coordinate

      • value: number

      Returns void

    • Return the selection simplified into non-overlapping boxes. Boxes are [x, y, width, height].

      Returns [number, number, number, number][]

    • Shift custom selections by a specified offset

      Parameters

      • offset_x: number
      • offset_y: number

      Returns void