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 | ||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| = DxImage:new = | = DxImage:new = | ||
| {{Client function}} {{FuncDef|element DxImage:new ( string path, float posX, float posY, float width, float height, element parent, boolean relative )}} | {{Client function}} | ||
| {{FuncDef|element DxImage:new ( string path, float posX, float posY, float width, float height, element parent, boolean relative )}} | |||
| '''Description:''' | '''Description:''' | ||
| Creates a DX image element.  | Creates a new DX-based image element. Images can be attached to parent elements, support transparency, custom styles, and optional parent-relative positioning. Each image instance is automatically registered in the DX library. | ||
| '''Parameters:''' | '''Parameters:''' | ||
| * path (string) – Path to the image file. Must exist. | |||
| path (string) – Path to the image file  | * posX, posY (float) – Position on screen. | ||
| * width, height (float) – Size of the image. | |||
| posX, posY (float) – Position on screen. | * parent (element) – Parent DX element to attach this image to (optional). | ||
| * relative (boolean) – Position relative to parent (optional). | |||
| width, height (float) – Size of the image. | |||
| parent (element) – Parent DX element (optional). | |||
| relative (boolean) – Position relative to parent (optional). | |||
| '''Returns:''' | '''Returns:''' | ||
| Line 23: | Line 19: | ||
| '''Methods:''' | '''Methods:''' | ||
| {| class="wikitable" style="width:100%; border:none;" | {| class="wikitable" style="width:100%; border:none;" | ||
| ! Method !! Description | ! Method !! Description | ||
| Ath: | |- | ||
| - | | Ath:destroy() || Destroys the image element and all its child elements. | ||
| Ath: | |- | ||
| - | | Ath:setVisible(boolean) || Shows or hides the image. | ||
| Ath: | |- | ||
| - | | Ath:setEnabled(boolean) || Enables or disables the image for interaction. | ||
| Ath: | |- | ||
| | Ath:setAlpha(number) || Sets the image transparency (0–255). | |||
| |} | |||
| } | |||
| '''Example:''' | '''Example:''' | ||
| <syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
| local  | local myImage = DxImage:new("images/logo.png", 100, 100, 200, 150) | ||
| myImage:setVisible(true) | |||
| myImage:setAlpha(200) | |||
| myImage:setPath("images/new_logo.png") | |||
| myImage:draw() | |||
| </syntaxhighlight> | </syntaxhighlight> | ||
| '''See also:''' | |||
| * [[Astrath]] – Main library page | |||
| * [[DxWindow:new]] – Page for window element reference | |||
| * [[DxLabel:new]] – Page for label element reference | |||
| * [[onClientRender]] – Event used to render DX elements | |||
Latest revision as of 20:10, 22 October 2025
DxImage:new
Description: Creates a new DX-based image element. Images can be attached to parent elements, support transparency, custom styles, and optional parent-relative positioning. Each image instance is automatically registered in the DX library.
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) – Parent DX element to attach this image to (optional).
- relative (boolean) – Position relative to parent (optional).
Returns:
- Returns the newly created DxImage element.
Methods:
| Method | Description | 
|---|---|
| Ath:destroy() | Destroys the image element and all its child elements. | 
| Ath:setVisible(boolean) | Shows or hides the image. | 
| Ath:setEnabled(boolean) | Enables or disables the image for interaction. | 
| Ath:setAlpha(number) | Sets the image transparency (0–255). | 
Example:
local myImage = DxImage:new("images/logo.png", 100, 100, 200, 150)
myImage:setVisible(true)
myImage:setAlpha(200)
myImage:setPath("images/new_logo.png")
myImage:draw()
See also:
- Astrath – Main library page
- DxWindow:new – Page for window element reference
- DxLabel:new – Page for label element reference
- onClientRender – Event used to render DX elements