A class for visualizing binary vectors as a bitmap using canvas

Constructors

Accessors

Methods

Constructors

  • Constructs a new BitPatternCanvas instance.

    Parameters

    • canvas: HTMLCanvasElement

      The target canvas element.

    • data: Uint8Array

      The binary vector data to visualize.

    • options: RenderOptions = {}

      Optional configuration.

      • cols

        The number of columns in the grid.

      • cellSize

        The size of each grid cell in pixels.

      • barSimilarity

        If greater than 0, applies a bar similarity effect. Useful for illustrating a similarity match score

      • pixelColor

        The color for active (set) bits.

      • noMatchPixelColor

        The color for non-matching pixels.

      • backgroundColor

        The background color of the canvas.

    Returns BitPatternCanvas

Accessors

  • get height(): number

    Computes the canvas height based on the number of bits and columns.

    Returns number

  • get width(): number

    Computes the canvas width based on columns and cell size.

    Returns number

Methods

  • Re-renders the visualization (useful for dynamic updates).

    Parameters

    • newData: Uint8Array

    Returns void

  • Updates the visualization options, merging new values with existing ones.

    Parameters

    • options: RenderOptions

      An object containing the properties to update.

    Returns void