DgsGetAlpha: Difference between revisions
Jump to navigation
Jump to search
m (DGS OOP Syntax changing) |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
float dgsGetAlpha ( element dgsElement ) | float dgsGetAlpha ( element dgsElement [, bool isAbsolute = false, bool includeParent = false ] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{DGS/OOP| | |||
Method = DGSElement:getAlpha| | |||
Variable = alpha| | |||
Counterpart = dgsSetAlpha | |||
}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''dgsElement:''' The dgs element in which you want to retrieve the alpha of. | *'''dgsElement:''' The dgs element in which you want to retrieve the alpha of. | ||
===Optional Arguments=== | |||
*'''isAbsolute:''' A bool determines whether the return value ranges from 0 to 255 or 0 to 1. | |||
*'''includeParent :''' A bool indicates the whether the parents' alpha will be calculated into the return value or not. | |||
===Returns=== | ===Returns=== | ||
Line 47: | Line 56: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=See Also= | |||
{{ | |||
==<span style="color:#eb3f00;text-shadow:0.05em 0.05em 0.2em #00000099;">General Functions</span>== | |||
{{DGS General Functions}} | |||
==<span style="color:#eb3f00;text-shadow:0.05em 0.05em 0.2em #00000099;">General Events</span>== | |||
{{DGS Events/General}} |
Latest revision as of 21:17, 3 May 2021
Alpha represents the transparency of a dgs element. This function allows retrieval of a dgs element's current alpha.
Syntax
float dgsGetAlpha ( element dgsElement [, bool isAbsolute = false, bool includeParent = false ] )
DGS OOP Syntax Help! I don't understand this!
- Method: DGSElement:getAlpha(...)
- Variable: .alpha
- Counterpart: dgsSetAlpha
Required Arguments
- dgsElement: The dgs element in which you want to retrieve the alpha of.
Optional Arguments
- isAbsolute: A bool determines whether the return value ranges from 0 to 255 or 0 to 1.
- includeParent : A bool indicates the whether the parents' alpha will be calculated into the return value or not.
Returns
This function returns a positive integer in between 0 and 1 of the dgs element's current alpha, or false if it could not be retrieved.
Example
This example provides a guiFade function, which allows you to fade in/out a DGS GUI.
DGS = exports.dgs function guiFade( gui, state ) if state == "in" then -- This state will fade in the DGS GUI fadeIn = setTimer(guiFade, 50, 1, gui, state) -- We loop the function to make it lower the alpha each 50 ms alpha = DGS:dgsGetAlpha(gui) -- We get the DGS GUI's actual alpha after each loop DGS:dgsSetAlpha(gui, alpha - 0.1) -- We set the DGS GUI's actual alpha after each loop if alpha == 0 then -- If the loop reached "0"... DGS:dgsSetVisible(gui, false) -- We set the DGS GUI visibility to 0 so it won't be clickable or editable killTimer(fadeIn) -- ... We kill the timer fadeIn = nil -- And to make sure it doesn't exist anymore, we set it to nil end elseif state == "out" then -- This state will fade out the DGS GUI DGS:dgsSetVisible(gui, true) -- Since the GUI will still be click-able, we'll set it's visibility to "false" fadeOut = setTimer(guiFade, 50, 1, gui, state) -- We loop the function to make it higher the alpha each 50 ms alpha = DGS:dgsGetAlpha(gui) -- We get the DGS GUI's actual alpha after each loop DGS:dgsSetAlpha(gui, alpha + 0.1) -- We set the DGS GUI's actual alpha after each loop if alpha == 1 then -- If the loop reached "1"... killTimer(fadeOut) -- ... We kill the timer fadeOut = nil -- And to make sure it doesn't exist anymore, we set it to nil end end end myWindow = DGS:dgsCreateWindow ( 0.30, 0.10, 0.5, 0.60, "DGS window title", true ) guiFade(myWindow,"out") -- NOTE: If you're using a button to pop up the DGS-Element. Use "dgsSetEnabled" along with the button. You'll have also to set a timer in order to disable it by the time it fades, either way it will bug.
See Also
General Functions
- dgsGetPosition
- dgsSetPosition
- dgsSetParent
- dgsGetParent
- dgsGetChild
- dgsGetChildren
- dgsGetSize
- dgsSetSize
- dgsGetType
- dgsSetLayer
- dgsGetLayer
- dgsSetCurrentLayerIndex
- dgsGetCurrentLayerIndex
- dgsGetLayerElements
- dgsGetProperty
- dgsSetProperty
- dgsSetPropertyInherit
- dgsGetProperties
- dgsSetProperties
- dgsGetVisible
- dgsSetVisible
- dgsGetEnabled
- dgsSetEnabled
- dgsGetPositionAlignment
- dgsSetPositionAlignment
- dgsGetAlpha
- dgsSetAlpha
- dgsGetFont
- dgsSetFont
- dgsGetText
- dgsSetText
- dgsGetPostGUI
- dgsSetPostGUI
- dgsGetInputEnabled
- dgsSetInputEnabled
- dgsGetInputMode
- dgsSetInputMode
- dgsAttachToAutoDestroy
- dgsDetachFromAutoDestroy
- dgsFocus
- dgsBlur
- dgsCreateFont
- dgsBringToFront
- dgsMoveToBack
- dgsGetScreenSize
- dgsGetCursorPosition
- dgsGetMouseEnterGUI
- dgsGetMouseLeaveGUI
- dgsIsMouseWithinGUI
- dgsSetSystemFont
- dgsGetSystemFont
- dgsGetElementsInLayer
- dgsGetElementsFromResource
- dgsGetFocusedGUI
- dgsImportFunction
- dgsImportOOPClass
- dgsG2DLoadHooker
- dgsSetRenderSetting
- dgsGetRenderSetting
- dgsSimulateClick
- dgsGetRootElement
- dgsAddMoveHandler
- dgsRemoveMoveHandler
- dgsIsMoveHandled
- dgsAddSizeHandler
- dgsRemoveSizeHandler
- dgsIsSizeHandled
- dgsAttachElements
- dgsDetachElements
- dgsElementIsAttached
- dgsAddPropertyListener
- dgsRemovePropertyListener
- dgsGetListenedProperties
- dgsSetMultiClickInterval
- dgsGetMultiClickInterval
- dgsSetMouseStayDelay
- dgsGetMouseStayDelay
- dgsCenterElement
- dgsSetElementKeeperEnabled
- dgsGetElementKeeperEnabled
- dgsSetClickingSound
- dgsGetClickingSound
- dgsSetClickingSoundVolume
- dgsGetClickingSoundVolume
General Events
- onDgsBlur
- onDgsCreate
- onDgsCursorTypeChange
- onDgsCursorStateChange
- onDgsDestroy
- onDgsElementRender
- onDgsElementMove
- onDgsElementSize
- onDgsElementEnter
- onDgsElementLeave
- onDgsFocus
- onDgsKey
- onDgsPositionChange
- onDgsPreRender
- onDgsRender
- onDgsElementScroll
- onDgsSizeChange
- onDgsTextChange
- onDgsWindowClose
- onDgsPropertyChange