Astrath:createImage: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "= DxImage:new = {{Client function}} {{FuncDef|element DxImage:new ( string path, float posX, float posY, float width, float height, element parent, boolean relative )}} '''Description:''' Creates a DX image element. An image element displays a static image from a file on the screen. '''Parameters:''' path (string) – Path to the image file (must exist). posX, posY (float) – Position on screen. width, height (float) – Size of the image. parent (element) – P...")
 
No edit summary
Line 1: Line 1:
= DxImage:new =
== DxImage:new ==
'''Description:'''
{{Client function}} {{FuncDef|element DxImage:new ( string path, float posX, float posY, float width, float height, element parent, boolean relative )}}
Creates a new DxImage element, which displays a static image on the screen. Uses table-based syntax with metatable.


'''Description:'''
'''Syntax:'''
Creates a DX image element. An image element displays a static image from a file on the screen.
<pre>
local image = DxImage:new(path, posX, posY, width, height, parent, relative)
</pre>


'''Parameters:'''
'''Parameters:'''
<pre>
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
</pre>


path (string) – Path to the image file (must exist).
'''Return Value:'''
 
<pre>
posX, posY (float) – Position on screen.
element - table - The newly created DxImage element
 
</pre>
width, height (float) – Size of the image.
 
parent (element) – Parent DX element (optional).
 
relative (boolean) – Position relative to parent (optional).
 
'''Returns:'''
: Returns the newly created DxImage element.


'''Methods:'''
'''Methods:'''
{| class="wikitable" style="width:100%; border:none;"
<pre>
 
image:destroy()            - Destroys the element and all its children
! Method !! Description
image:setVisible(boolean) - Sets the visibility
Ath:setVisible(boolean)
image:setEnabled(boolean) - Enables or disables the element
-
image:setAlpha(int)       - Sets transparency (0–255)
Ath:setEnabled(boolean)
image:setPath(string)      - Changes the image file path (must exist)
-
image:draw()               - Draws the image using its defined style
Ath:setAlpha(int)
</pre>
-
Ath:setPath(string path)
-
Ath:destroy()
}


'''Example:'''
'''Example:'''
<syntaxhighlight lang="lua">
<pre>
local img = DxImage:new("images/logo.png", 100, 100, 200, 150)
local img = DxImage:new("images/logo.png", 100, 100, 200, 150)
img:setAlpha(200)
img:setAlpha(200)
img:setVisible(true)
img:setVisible(true)
</syntaxhighlight>
img:setPath("images/new_logo.png")
img:draw()
</pre>
 
'''See Also:'''
DxWindow:new, DxLabel:new, DxButton:new

Revision as of 20:01, 22 October 2025

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