Options
All
  • Public
  • Public/Protected
  • All
Menu

Common drawing functions

Hierarchy

  • DrawUtils

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

  • new DrawUtils(context: CanvasRenderingContext2D, theme: Theme): DrawUtils
  • DrawUtils contructor

    Parameters

    • context: CanvasRenderingContext2D
    • theme: Theme

    Returns DrawUtils

Properties

Private ctx

ctx: CanvasRenderingContext2D

Private theme

theme: Theme

Methods

border

  • border(x: number, y: number, width: number, height: number, color: string, borderWidth: number): void
  • Draws border (always transparent rectangle, just 4 lines)

    Parameters

    • x: number
    • y: number
    • width: number
    • height: number
    • color: string
    • borderWidth: number

    Returns void

line

  • line(x1: number, y1: number, x2: number, y2: number, color: string, width?: number): void
  • Draws a line on canvas

    Parameters

    • x1: number
    • y1: number
    • x2: number
    • y2: number
    • color: string
    • Default value width: number = 1

    Returns void

roundRect

  • roundRect(x: number, y: number, width: number, height: number, radius?: number, fillStyle?: string, strokeStyle?: string, strokeWidth?: number): void
  • Draw rounded rectangle

    Parameters

    • x: number
    • y: number
    • width: number
    • height: number
    • Default value radius: number = 5
    • Default value fillStyle: string = this.theme.backgroundColor
    • Default value strokeStyle: string = this.theme.gridColor
    • Default value strokeWidth: number = 1

    Returns void

text

  • text(x: number, y: number, text: string, color?: string, xAlign?: string, yAlign?: string, size?: number, style?: string, font?: string): TextMetrics
  • Draws a text on canvas

    Parameters

    • x: number
    • y: number
    • text: string
    • Default value color: string = this.theme.textColor
    • Default value xAlign: string = "left"
    • Default value yAlign: string = "top"
    • Default value size: number = this.theme.textSize
    • Default value style: string = this.theme.fontStyle
    • Default value font: string = this.theme.font

    Returns TextMetrics

    size of text

textMaxWidth

  • textMaxWidth(x: number, y: number, text: string, maxWidth: number, color?: string, xAlign?: string, yAlign?: string, size?: number, style?: string, font?: string): void
  • Draws a text on canvas if maximum width is not more then maxWidtx

    Parameters

    • x: number
    • y: number
    • text: string
    • maxWidth: number
    • Default value color: string = this.theme.textColor
    • Default value xAlign: string = "left"
    • Default value yAlign: string = "top"
    • Default value size: number = this.theme.textSize
    • Default value style: string = this.theme.fontStyle
    • Default value font: string = this.theme.font

    Returns void

Generated using TypeDoc