Module components_ui_image

UI component that draws an image or a colored placeholder on a canvas.

Info:

  • Author: Sharper Dev

Functions

Image:new (gameObject) Creates an enabled image component with a white tint.
Image:setCanvas (canvas) Adds this image to a canvas, removing it from the previous canvas if set.
Image:setImage (imgPath) Loads an image from the image bank and updates its dimensions.
Image:setColor (r, g, b, a) Sets the image tint; alpha defaults to 255 when omitted.
Image:destroy () Unloads the image and removes this component from its canvas on scene switch.
Image:render () Draws the image or its placeholder; invoked by the renderer's registered render task.


Functions

Image:new (gameObject)
Creates an enabled image component with a white tint.

Parameters:

  • gameObject table Game object that owns this component.

Returns:

    table The new Image component.

Usage:

    local image = gameObject:addComponent("Image")
Image:setCanvas (canvas)
Adds this image to a canvas, removing it from the previous canvas if set.

Parameters:

  • canvas table Canvas on which to render this image.

Returns:

    table This image component.

Usage:

    image:setCanvas(canvas)
Image:setImage (imgPath)
Loads an image from the image bank and updates its dimensions.

Parameters:

  • imgPath string Path or bank ID accepted by the image bank.

Returns:

    table This image component.

Usage:

    image:setImage(imgPath)
Image:setColor (r, g, b, a)
Sets the image tint; alpha defaults to 255 when omitted.

Parameters:

  • r number Red color channel.
  • g number Green color channel.
  • b number Blue color channel.
  • a number|nil Alpha channel, defaulting to 255.

Returns:

    table This image component.

Usage:

    image:setColor(r, g, b, a)
Image:destroy ()
Unloads the image and removes this component from its canvas on scene switch.
Image:render ()
Draws the image or its placeholder; invoked by the renderer's registered render task.
generated by LDoc 1.5.0 Last updated 2026-10-04 12:53:32