Phaser API Documentation

  Version: 
Filter
This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord
Namespace: Smoothing
Phaser.Display.Canvas.Smoothing

Methods

<static> getPrefix(context)
Focus
Focus

Description:

Gets the Smoothing Enabled vendor prefix being used on the given context, or null if not set.

Parameters:

name type description
context CanvasRenderingContext2D | WebGLRenderingContext

The canvas context to check.

Returns:
Description:

The name of the property on the context which controls image smoothing (either imageSmoothingEnabled or a vendor-prefixed version thereof), or null if not supported.

Type:
  • string
Examples:
Since: 3.0.0
Focus
Focus
<static> enable(context)
Focus
Focus

Description:

Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. By default browsers have image smoothing enabled, which isn't always what you visually want, especially when using pixel art in a game. Note that this sets the property on the context itself, so that any image drawn to the context will be affected. This sets the property across all current browsers but support is patchy on earlier browsers, especially on mobile.

Parameters:

name type description
context CanvasRenderingContext2D | WebGLRenderingContext

The context on which to enable smoothing.

Returns:
Description:

The provided context.

Type:
  • CanvasRenderingContext2D
  • WebGLRenderingContext
Examples:
Since: 3.0.0
Focus
Focus
<static> disable(context)
Focus
Focus

Description:

Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. By default browsers have image smoothing enabled, which isn't always what you visually want, especially when using pixel art in a game. Note that this sets the property on the context itself, so that any image drawn to the context will be affected. This sets the property across all current browsers but support is patchy on earlier browsers, especially on mobile.

Parameters:

name type description
context CanvasRenderingContext2D | WebGLRenderingContext

The context on which to disable smoothing.

Returns:
Description:

The provided context.

Type:
  • CanvasRenderingContext2D
  • WebGLRenderingContext
Examples:
Since: 3.0.0
Focus
Focus
<static> isEnabled(context)
Focus
Focus

Description:

Returns true if the given context has image smoothing enabled, otherwise returns false. Returns null if no smoothing prefix is available.

Parameters:

name type description
context CanvasRenderingContext2D | WebGLRenderingContext

The context to check.

Returns:
Description:

true if smoothing is enabled on the context, otherwise false. null if not supported.

Type:
  • boolean
Examples:
Since: 3.0.0
Focus
Focus