Skip to main content
Version: Phaser v4.0.0

Phaser.Display.Canvas.Smoothing

Scope: static

Source: src/display/canvas/Smoothing.js#L10
Since: 3.0.0

Static functions

disable

<static> disable(context)

Description:

Disables the Image Smoothing property on the given context. 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:

nametypeoptionaldescription
contextCanvasRenderingContext2D | WebGLRenderingContextNoThe context on which to disable smoothing.

Returns: CanvasRenderingContext2D, WebGLRenderingContext - The provided context.

Source: src/display/canvas/Smoothing.js#L80
Since: 3.0.0


enable

<static> enable(context)

Description:

Enables the Image Smoothing property on the given context. 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:

nametypeoptionaldescription
contextCanvasRenderingContext2D | WebGLRenderingContextNoThe context on which to enable smoothing.

Returns: CanvasRenderingContext2D, WebGLRenderingContext - The provided context.

Source: src/display/canvas/Smoothing.js#L51
Since: 3.0.0


getPrefix

<static> getPrefix(context)

Description:

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

Parameters:

nametypeoptionaldescription
contextCanvasRenderingContext2D | WebGLRenderingContextNoThe canvas context to check.

Returns: string - 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.

Source: src/display/canvas/Smoothing.js#L24
Since: 3.0.0


isEnabled

<static> isEnabled(context)

Description:

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

Parameters:

nametypeoptionaldescription
contextCanvasRenderingContext2D | WebGLRenderingContextNoThe context to check.

Returns: boolean - true if smoothing is enabled on the context, otherwise false. null if not supported.

Source: src/display/canvas/Smoothing.js#L109
Since: 3.0.0