Skip to content

CanvasTexture

The CanvasTexture class represents a drawable canvas within the engine framework, allowing for the creation and manipulation of textures through various drawing operations, making it ideal for dynamic visual content generation and customization in applications requiring real-time graphical updates.

Inherits from

Item

Usage

To use this class, add the following require at the top of your script:

local CanvasTexture = require 'engine/items/canvastexture'

Reference

create

static create(self, attributes)

Create a new canvasTexture

Parameters

  • self
  • attributes (table): list of attributes. without, the canvasTexture will be created with default values

Returns

  • CanvasTexture: of the created canvasTexture.

getMaterial

getMaterial()

Get the alpha map of the material.

Returns

  • Texture: alpha map texture.

getTexture

getTexture()

Get the texture.

Returns

  • Texture: texture.

clear

clear()

drawRect

drawRect(left, top, width, height, color, radius)

Parameters

  • left
  • top
  • width
  • height
  • color
  • radius

clearRect

clearRect(left, top, width, height)

Parameters

  • left
  • top
  • width
  • height

drawTexture

drawTexture(texture, left, top, width, height, tint)

Parameters

  • texture
  • left
  • top
  • width
  • height
  • tint

drawText

drawText(text, left, top, fontSize, font, color)

Parameters

  • text
  • left
  • top
  • fontSize
  • font
  • color

render

render()

measureText

measureText(text, fontSize, font)

Parameters

  • text
  • fontSize
  • font