Astrath:createImage: Difference between revisions
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:''' | |||
Creates a new DxImage element, which displays a static image on the screen. Uses table-based syntax with metatable. | |||
''' | '''Syntax:''' | ||
<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> | |||
'''Return Value:''' | |||
<pre> | |||
element - table - The newly created DxImage element | |||
</pre> | |||
''' | |||
'''Methods:''' | '''Methods:''' | ||
<pre> | |||
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 | ||
</pre> | |||
- | |||
'''Example:''' | '''Example:''' | ||
< | <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) | ||
</ | 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