Options
All
  • Public
  • Public/Protected
  • All
Menu
classdesc

Creates a DuckEngine CanvasRenderer

description

The CanvasRenderer Class. Renders everything using the RendererPipeline to pool what to draw

since

2.1.0

Hierarchy

Index

Constructors

constructor

Properties

ctx

ctx: CanvasRenderingContext2D
memberof

CanvasRenderer

description

The Canvas rendering context

since

2.1.0

game

game: Game

pipeline

memberof

CanvasRenderer

description

The RenderingPipeline, handles and manages what needs to be drawn and updated

since

2.1.0

Methods

clearFrame

  • clearFrame(): void

clearRect

  • clearRect(x: number, y: number, w: number, h: number): void
  • memberof

    CanvasRenderer

    description

    Clears an area

    since

    2.1.0

    Parameters

    • x: number

      X position

    • y: number

      Y position

    • w: number

      Width of area to clear

    • h: number

      Height of area to clear

    Returns void

drawCircle

  • drawCircle(x: number, y: number, r: number, color: string): void

drawRect

  • drawRect(x: number, y: number, w: number, h: number, color: string): void

drawRoundRect

  • drawRoundRect(x: number, y: number, w: number, h: number, r: number, color: string): void
  • memberof

    CanvasRenderer

    description

    Fills a roundRect

    since

    2.1.0

    Parameters

    • x: number

      X position

    • y: number

      Y position

    • w: number

      Width of roundRect

    • h: number

      Height of roundRect

    • r: number

      Radius of roundRect

    • color: string

      Color to fill roundRect with

    Returns void

drawSprite

  • drawSprite(x: number, y: number, w: number, h: number, texture: TextureBase<"image">, currentRow?: number, currentCol?: number): void
  • memberof

    CanvasRenderer

    description

    Draws a sprite

    since

    2.1.0

    Parameters

    • x: number

      X position

    • y: number

      Y position

    • w: number

      Width of roundRect

    • h: number

      Height of roundRect

    • texture: TextureBase<"image">

      Texture to use for the Sprite

    • Optional currentRow: number
    • Optional currentCol: number

    Returns void

drawText

  • drawText(text: string, x: number, y: number, maxWidth?: number): void
  • memberof

    CanvasRenderer

    description

    Draws text to the screen, must set font with this.setFont first and color with this.setFillColor

    since

    2.1.0

    Parameters

    • text: string

      Text to draw

    • x: number

      X Position

    • y: number

      Y Position

    • Optional maxWidth: number

    Returns void

measureText

  • measureText(font: string, text: string): TextMetrics

render

  • render(deltaTime: number): void
  • memberof

    CanvasRenderer

    description

    Gets the poolStack from the pipeline and ticks, updates, and renders the scene and renderables

    since

    2.1.0

    Parameters

    • deltaTime: number

      Time passed since last frame

    Returns void

restore

  • restore(): void

save

  • save(): void

scale

  • scale(x: number, y: number): void

setBlendMode

  • setBlendMode(blendMode: "color" | "multiply" | "source-over" | "source-in" | "source-out" | "source-atop" | "destination-over" | "destination-in" | "destination-out" | "destination-atop" | "lighter" | "copy" | "xor" | "screen" | "overlay" | "darken" | "lighten" | "color-dodge" | "color-burn" | "hard-light" | "soft-light" | "difference" | "exclusion" | "hue" | "saturation" | "luminosity"): void
  • memberof

    CanvasRenderer

    description

    Sets the blend mode / globalCompositionOperation

    since

    2.1.0

    Parameters

    • blendMode: "color" | "multiply" | "source-over" | "source-in" | "source-out" | "source-atop" | "destination-over" | "destination-in" | "destination-out" | "destination-atop" | "lighter" | "copy" | "xor" | "screen" | "overlay" | "darken" | "lighten" | "color-dodge" | "color-burn" | "hard-light" | "soft-light" | "difference" | "exclusion" | "hue" | "saturation" | "luminosity"

      Blend Mode

    Returns void

setFillColor

  • setFillColor(color: string): void

setFont

  • setFont(font: string): void

setLineWidth

  • setLineWidth(width: number): void

setStrokeColor

  • setStrokeColor(color: string): void

strokeText

  • strokeText(text: string, x: number, y: number, maxWidth?: number): void
  • memberof

    CanvasRenderer

    description

    Strokes text to the screen, must set font with this.setFont first and color with this.setStrokeColor

    since

    2.1.0

    Parameters

    • text: string

      Text to draw

    • x: number

      X Position

    • y: number

      Y Position

    • Optional maxWidth: number

    Returns void

transform

  • transform(a: number, b: number, c: number, d: number, e: number, f: number): void

translate

  • translate(x: number, y: number): void

Generated using TypeDoc