Skip to main content

ExcaliburGraphicsContextWebGL

Implements

Index

Constructors

constructor

Properties

publicbackgroundColor

backgroundColor: Color = Color.ExcaliburBlue

Set the background color of the graphics context, default is Color.ExcaliburBlue

debug

debug: ExcaliburGraphicsContextWebGLDebug = ...

Access the debug drawing api

publicmaterialScreenTexture

materialScreenTexture: WebGLTexture

publicreadonlymultiSampleAntialiasing

multiSampleAntialiasing: boolean = true

publicreadonlypixelArtSampler

pixelArtSampler: boolean = false

Whether the pixel art sampler is enabled for smooth sub pixel anti-aliasing

publicoptionalreadonlysamples

samples?: number

publicreadonlysmoothing

smoothing: boolean = false

Native context smoothing

publicsnapToPixel

snapToPixel: boolean = false

Snaps the drawing x/y coordinate to the nearest whole pixel

publictextureLoader

textureLoader: TextureLoader

publicreadonlytransparency

transparency: boolean = true

publicuseDrawSorting

useDrawSorting: boolean = true

Excalibur will automatically sort draw calls by z and priority for maximal draw performance, this can disrupt a specific desired painter order.

To force a specific draw call order, use ExcaliburGraphicsContext.z

By default useDrawSorting is true, to opt out set this to false

publicuvPadding

uvPadding: number = 0.01

UV padding in pixels to use in internal image rendering to prevent texture bleed

Accessors

publicheight

  • get height(): number
  • Returns number

publicmaterial

  • Gets or sets the material to be used in the current context's drawings

    This allows customs shaders to be used but draw calls are no longer batched by default.


    Returns Material

  • Gets or sets the material to be used in the current context's drawings

    This allows customs shaders to be used but draw calls are no longer batched by default.


    Parameters

    Returns void

publicopacity

  • get opacity(): number
  • set opacity(value: number): void
  • Sets the opacity of the current Graphic being drawn, default is 1


    Returns number

  • Sets the opacity of the current Graphic being drawn, default is 1


    Parameters

    • value: number

    Returns void

publicortho

publictint

  • Sets the tint color to be multiplied by any images drawn, default is black 0xFFFFFFFF


    Returns Color

  • Sets the tint color to be multiplied by any images drawn, default is black 0xFFFFFFFF


    Parameters

    Returns void

publicwidth

  • get width(): number
  • Returns number

publicz

  • get z(): number
  • set z(value: number): void
  • Set the current z context for the graphics context. Draw calls issued to the context will use this z to inform their sort order.

    Note it is important to all ExcaliburGraphicsContext.save and ExcaliburGraphicsContext.restore when modifying state.


    Returns number

  • Set the current z context for the graphics context. Draw calls issued to the context will use this z to inform their sort order.

    Note it is important to all ExcaliburGraphicsContext.save and ExcaliburGraphicsContext.restore when modifying state.


    Parameters

    • value: number

    Returns void

Methods

publicaddPostProcessor

  • Add a post processor to the graphics context

    Post processors are run in the order they were added.


    Parameters

    Returns void

publicbeginDrawLifecycle

  • beginDrawLifecycle(): void
  • Returns void

publiccheckIfResolutionSupported

  • checkIfResolutionSupported(dim: Resolution): boolean
  • Checks the underlying webgl implementation if the requested internal resolution is supported


    Parameters

    Returns boolean

clear

  • clear(): void
  • Clears the screen with the current background color


    Returns void

publicclearPostProcessors

  • clearPostProcessors(): void
  • Remove all post processors from the graphics context


    Returns void

publiccreateMaterial

  • Creates and initializes the material which compiles the internal shader


    Parameters

    Returns Material

    Material

publiccreateShader

publicdispose

  • dispose(): void
  • Returns void

publicdraw

  • draw<TRenderer>(rendererName: TRenderer[type], ...args: Parameters<TRenderer[draw]>): void
  • Type parameters

    • TRenderer: RendererPlugin

    Parameters

    • rendererName: TRenderer[type]
    • rest...args: Parameters<TRenderer[draw]>

    Returns void

publicdrawCircle

  • drawCircle(pos: Vector, radius: number, color: Color, stroke?: Color, thickness?: number): void
  • Draw a circle to the Excalibur Graphics context


    Parameters

    • pos: Vector
    • radius: number
    • color: Color
    • optionalstroke: Color

      Optionally specify the stroke color

    • optionalthickness: number

    Returns void

drawImage

  • drawImage(image: HTMLImageSource, x: number, y: number): void
  • drawImage(image: HTMLImageSource, x: number, y: number, width: number, height: number): void
  • drawImage(image: HTMLImageSource, sx: number, sy: number, swidth?: number, sheight?: number, dx?: number, dy?: number, dwidth?: number, dheight?: number): void
  • Draw an image to the Excalibur Graphics context at an x and y coordinate using the images width and height


    Parameters

    Returns void

publicdrawLine

  • Draw a solid line to the Excalibur Graphics context


    Parameters

    Returns void

publicdrawRectangle

  • drawRectangle(pos: Vector, width: number, height: number, color: Color, stroke?: Color, strokeThickness?: number): void
  • Draw a solid rectangle to the Excalibur Graphics context


    Parameters

    • pos: Vector
    • width: number
    • height: number
    • color: Color
    • optionalstroke: Color
    • optionalstrokeThickness: number

    Returns void

publicendDrawLifecycle

  • endDrawLifecycle(): void
  • Returns void

flush

  • flush(): void
  • Flushes all batched rendering to the screen


    Returns void

publicget

  • get(rendererName: string): RendererPlugin
  • Parameters

    • rendererName: string

    Returns RendererPlugin

publicgetTransform

  • Gets the current transform


    Returns AffineMatrix

publicmultiply

  • Multiplies the current transform by a matrix


    Parameters

    Returns void

publicregister

  • register<T>(renderer: T): void
  • Type parameters

    • T: RendererPlugin

    Parameters

    • renderer: T

    Returns void

publicremovePostProcessor

  • Remove a specific post processor from the graphics context


    Parameters

    Returns void

publicresetTransform

  • resetTransform(): void
  • Resets the current transform to the identity matrix


    Returns void

publicrestore

  • restore(): void
  • Restore the state of the canvas from the stack


    Returns void

publicrotate

  • rotate(angle: number): void
  • Rotate the context about the current origin


    Parameters

    • angle: number

    Returns void

publicsave

  • save(): void
  • Save the current state of the canvas to the stack (transforms and opacity)


    Returns void

publicscale

  • scale(x: number, y: number): void
  • Scale the context by an x and y factor


    Parameters

    • x: number
    • y: number

    Returns void

publictransform

publictranslate

  • translate(x: number, y: number): void
  • Translate the origin of the context by an x and y


    Parameters

    • x: number
    • y: number

    Returns void

publicupdatePostProcessors

  • updatePostProcessors(elapsedMs: number): void
  • Parameters

    • elapsedMs: number

    Returns void

publicupdateViewport

  • Update the context with the current viewport dimensions (used in resizing)


    Parameters

    Returns void