Astrath:createShape

From Multi Theft Auto: Wiki
Jump to navigation Jump to search

DxShape:new

Template:FuncDef

Description: Creates a new DX-based shape element. Shapes can have custom colors, hover effects, and rounded corners. Each shape instance is automatically registered in the DX library.

Parameters:

  • posX, posY (float) – Position on screen.
  • width, height (float) – Size of the shape.
  • parent (element) – Parent DX element to attach this shape to (optional).
  • relative (boolean) – Position relative to parent (optional).
  • color (table / tocolor) – Main color of the shape (optional, default: grey).

Returns:

Returns the newly created DxShape element.

Methods:

Method Description
Ath:destroy() Destroys the shape and all its child elements.
Ath:setVisible(boolean) Shows or hides the shape.
Ath:setEnabled(boolean) Enables or disables the shape for interaction.
Ath:setHoverable(boolean) Enables or disables hover effect.
Ath:setColor(r, g, b, a, type) Sets main or hover color of the shape.

Example:

local myShape = DxShape:new(100, 100, 200, 150)
myShape:setVisible(true)
myShape:setHoverable(true)
myShape:setColor(150, 150, 150, 255, "mainColor")
myShape:draw()

See also: