Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "Util/DrawUtil"

Index

Interfaces

Type aliases

Functions

Type aliases

LineCapStyle

LineCapStyle: "butt" | "round" | "square"

A canvas linecap style. "butt" is the default flush style, "round" is a semi-circle cap with a radius half the width of the line, and "square" is a rectangle that is an equal width and half height cap.

Functions

circle

  • circle(ctx: CanvasRenderingContext2D, x: number, y: number, radius: number, stroke?: Color, fill?: Color): void
  • Parameters

    • ctx: CanvasRenderingContext2D
    • x: number
    • y: number
    • radius: number
    • Default value stroke: Color = Color.White
    • Default value fill: Color = null

    Returns void

line

  • line(ctx: CanvasRenderingContext2D, color?: Color, x1: number, y1: number, x2: number, y2: number, thickness?: number, cap?: LineCapStyle): void
  • Draw a line on canvas context

    Parameters

    • ctx: CanvasRenderingContext2D

      The canvas context

    • Default value color: Color = Color.Red

      The color of the line

    • x1: number

      The start x coordinate

    • y1: number

      The start y coordinate

    • x2: number

      The ending x coordinate

    • y2: number

      The ending y coordinate

    • Default value thickness: number = 1

      The line thickness

    • Default value cap: LineCapStyle = "butt"

      The LineCapStyle (butt, round, or square)

    Returns void

point

  • point(ctx: CanvasRenderingContext2D, color?: Color, point: Vector): void
  • Draw the vector as a point onto the canvas.

    Parameters

    • ctx: CanvasRenderingContext2D
    • Default value color: Color = Color.Red
    • point: Vector

    Returns void

roundRect

  • roundRect(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius?: number | BorderRadius, stroke?: Color, fill?: Color): void
  • Draw a round rectangle on a canvas context

    Parameters

    • ctx: CanvasRenderingContext2D

      The canvas context

    • x: number

      The top-left x coordinate

    • y: number

      The top-left y coordinate

    • width: number

      The width of the rectangle

    • height: number

      The height of the rectangle

    • Default value radius: number | BorderRadius = 5

      The border radius of the rectangle

    • Default value stroke: Color = Color.White

      The Color to stroke rectangle with

    • Default value fill: Color = null

      The Color to fill rectangle with

    Returns void

vector

  • vector(ctx: CanvasRenderingContext2D, color: Color, origin: Vector, vector: Vector, scale?: number): void
  • Draw the vector as a line onto the canvas starting a origin point.

    Parameters

    • ctx: CanvasRenderingContext2D
    • color: Color
    • origin: Vector
    • vector: Vector
    • Default value scale: number = 1

    Returns void