Astrath:createImage

From Multi Theft Auto: Wiki
Revision as of 20:01, 22 October 2025 by Sybellex (talk | contribs)
Jump to navigation Jump to search

DxImage:new

Description: Creates a new DxImage element, which displays a static image on the screen. Uses table-based syntax with metatable.

Syntax:

local image = DxImage:new(path, posX, posY, width, height, parent, relative)

Parameters:

path      - string - Path to the image file (must exist)
posX      - float  - X position on screen
posY      - float  - Y position on screen
width     - float  - Width of the image
height    - float  - Height of the image
parent    - element (optional) - Parent DX element
relative  - boolean (optional) - Whether position is relative to parent

Return Value:

element - table - The newly created DxImage element

Methods:

image:destroy()            - Destroys the element and all its children
image:setVisible(boolean)  - Sets the visibility
image:setEnabled(boolean)  - Enables or disables the element
image:setAlpha(int)        - Sets transparency (0–255)
image:setPath(string)      - Changes the image file path (must exist)
image:draw()               - Draws the image using its defined style

Example:

local img = DxImage:new("images/logo.png", 100, 100, 200, 150)
img:setAlpha(200)
img:setVisible(true)
img:setPath("images/new_logo.png")
img:draw()

See Also: DxWindow:new, DxLabel:new, DxButton:new