Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Util

Index

Constructors

constructor

Properties

Static DEBUG

DEBUG: boolean = false

Static Private devicePixelRatio

devicePixelRatio: number = ...

Methods

Static coordToIndex

  • coordToIndex(x: number, y: number, gridHeight: number): number
  • Converts 2-D coordinates to their corresponding index in a 1-D array representation

    Parameters

    • x: number

      The x coordinate

    • y: number

      The y coordinate

    • gridHeight: number

      The width of the 2-D representation (the grid height)

    Returns number

    The corresponding index

Static drawRoundedRectangle

  • drawRoundedRectangle(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius?: number, fill?: boolean, stroke?: boolean): void
  • Draws a rounded rectangle Adapted from https://stackoverflow.com/a/3368118/2234742

    Parameters

    • ctx: CanvasRenderingContext2D

      The canvas context to draw on

    • x: number

      The x coordinate at which to draw the rounded rectangle

    • y: number

      The y coordinate at which to draw the rounded rectangle

    • width: number

      The width of the rounded rectangle to draw

    • height: number

      The height of the rounded rectangle to draw

    • radius: number = 5

      The border radius of the rounded rectangle

    • fill: boolean = false

      Whether the rectangle should be filled

    • stroke: boolean = true

      Whether the rectangle should be stroked

    Returns void

Static getDevicePixelRatio

  • getDevicePixelRatio(): number
  • Gets the current devicePixelRatio in a performant way

    Returns number

    The device pixel ratio

Static indexToCoord

  • indexToCoord(index: number, gridHeight: number): [x: number, y: number]
  • Converts a 1-D array index into an (x, y) coordinate in its corresponding 2-D representation

    Parameters

    • index: number

      the 1D array index

    • gridHeight: number

      The width of the 2-D representation (the grid height)

    Returns [x: number, y: number]

    • The corresponding x and y coordinates

Generated using TypeDoc