Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "main"

Index

Functions

flatten

  • flatten(grid: boolean[][]): Array<boolean>
  • Takes a matrix of boolean values and flattens it, i.e. returns a one-dimensional array with all the rows concatenated. Moreover, if the length of the rows is not evenly divisible by 8, they are padded to a length which is divisible by 8 by appending the required number of false values.

    Parameters

    • grid: boolean[][]

      Grid to be flattened

    Returns Array<boolean>

    Flattened grid

formatBytes

  • formatBytes(bytes: Array<number>): string
  • Takes a list of numbers, converts them to hexadecimal notation and arranges them into groups of 12, where each value is delimited by a comma and each group is separated by a line break.

    Parameters

    • bytes: Array<number>

      Array of numbers to be formatted

    Returns string

    A string of formatted hex values

generateXBM

  • generateXBM(name: string, grid: boolean[][], arduinoHeader?: boolean): string
  • Takes a grid of boolean values and converts it into XBM-formatted data which is returned as a string. Optionally, the parameter arduinoHeader can be set to true to generate an XBM file specifically for Arduino.

    Parameters

    • name: string

      Name of the variable to be used in the output file

    • grid: boolean[][]

      The grid from which the XBM data shall be generated

    • Default value arduinoHeader: boolean = false

      Generate Arduino-compatible XBM (default false)

    Returns string

    XBM-formatted data

getHeight

  • getHeight(data: string): number
  • Takes XBM data as a string and tries to extract the height of the image by looking for the corresponding #define statement and returns it. If no such statement can be found, 0 is returned.

    Parameters

    • data: string

      XBM formatted data as a string

    Returns number

    The height specified in the file, 0 on error

getPixels

  • getPixels(data: string): Array<string> | undefined
  • Takes XBM data as a string and tries to extract the data portion of the image by looking for a block of hex values delimited by curly braces. If found, the block is split using the comma character as delimiter and the hex values are converted to binary strings which are padded to the length of a byte. This is then converted to an array of characters and returned. If no block matching the conditions is found, undefined is returned.

    Parameters

    • data: string

      XBM formatted data as a string

    Returns Array<string> | undefined

    An array containing the data portion of the input as binary strings

getWidth

  • getWidth(data: string): number
  • Takes XBM data as a string and tries to extract the width of the image by looking for the corresponding #define statement and returns it. If no such statement can be found, 0 is returned.

    Parameters

    • data: string

      XBM formatted data as a string

    Returns number

    The width specified in the file, 0 on error

readXBM

  • readXBM(data: string): boolean[][]
  • Takes a string of XBM-formatted data, parses it and returns a matrix of the given width and height containing the data from the XBM as boolean values. If the contents of the string cannot be parsed, an error is thrown.

    Parameters

    • data: string

      String containing XBM-formatted data

    Returns boolean[][]

    A matrix of boolean values

Generated using TypeDoc