CanvasTexture Class

Extends Texture
Module: Textures

Canvas textures can be used to draw content to the texture during runtime, using the context property.

Canvas textures always start with black background and a red text "Canvas Texture".

Constructor

CanvasTexture

(
  • width
  • height
  • mapping
  • wrapS
  • wrapT
  • magFilter
  • minFilter
  • format
  • type
  • anisotropy
  • encoding
)

Parameters:

  • width Number

    Canvas width

  • height Number

    Canvas height

  • mapping Number
  • wrapS Number
  • wrapT Number
  • magFilter Number
  • minFilter Number
  • format Number
  • type Number
  • anisotropy Number
  • encoding Number

Item Index

Properties

Methods

clear

(
  • color
)

Clear canvas texture with a background color.

Uses the internal context to draw a rect to fill the canvas.

Parameters:

  • color String

toJSON

(
  • meta
)

Create JSON description for canvas texture, canvas image is not serialized.

Parameters:

  • meta Object

updateSize

()

Update the size of the canvas texture.

The texture is image is reset to the default.

Should be called after changing the width or height properties.

Properties

context

Context2D

Canvas context 2D, can be used to draw content do the canvas texture.

height

Number

Canvas height.

image

DOM

Image is used to store a DOM canvas element.

width

Number

Canvas width.