GuiGetAlpha: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 5: | Line 5: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
float guiGetAlpha ( element guiElement ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 12: | Line 12: | ||
===Returns=== | ===Returns=== | ||
This function returns a positive integer in between 0 and 1 of the gui element's current alpha, or false if it could not be retrieved. | |||
This function returns a positive integer in between 0 and | |||
==Example== | ==Example== | ||
Line 21: | Line 20: | ||
if state == "out" then --if the user specifies he wants to fade out an element | if state == "out" then --if the user specifies he wants to fade out an element | ||
local currentAlpha = guiGetAlpha ( guiElement )--get the current alpha | local currentAlpha = guiGetAlpha ( guiElement )--get the current alpha | ||
local newAlpha = currentAlpha - 4 --set the alpha to 4 less (more transparent) | local newAlpha = currentAlpha - 0.4 --set the alpha to 4 less (more transparent) | ||
--ensure that the alpha is not below 0, if it is, set it to 0 | --ensure that the alpha is not below 0, if it is, set it to 0 | ||
if newAlpha < 0 then newAlpha = 0 end | if newAlpha < 0 then newAlpha = 0 end | ||
Line 33: | Line 32: | ||
elseif state == "in" then --else, if the user specifies he wants to fade out an element | elseif state == "in" then --else, if the user specifies he wants to fade out an element | ||
local currentAlpha = guiGetAlpha ( guiElement )--get the current alpha | local currentAlpha = guiGetAlpha ( guiElement )--get the current alpha | ||
local newAlpha = currentAlpha + 4 --set the alpha to 4 more(less transparent) | local newAlpha = currentAlpha + 0.4 --set the alpha to 4 more(less transparent) | ||
--ensure that the alpha is not above 255, if it is, set it to 255 | --ensure that the alpha is not above 255, if it is, set it to 255 | ||
if newAlpha > | if newAlpha > 1 then newAlpha = 1 end | ||
--set the new alpha | --set the new alpha | ||
guiSetAlpha ( guiElement, newAlpha ) | guiSetAlpha ( guiElement, newAlpha ) | ||
--if the new alpha is not completely opaque already | --if the new alpha is not completely opaque already | ||
if newAlpha ~= | if newAlpha ~= 1 then | ||
--call this function to fade in some more 50ms later | --call this function to fade in some more 50ms later | ||
setTimer ( fadeElement, 50, 1, guiElement, state ) | setTimer ( fadeElement, 50, 1, guiElement, state ) | ||
Line 46: | Line 45: | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Edited by JR10, was wrong, the Alpha is a float between 0 and 1 | |||
==See Also== | ==See Also== | ||
{{GUI_functions}} | {{GUI_functions}} |
Revision as of 00:44, 4 September 2011
Alpha represents the transparency of a gui element. This function allows retrieval of a gui element's current alpha.
Syntax
float guiGetAlpha ( element guiElement )
Required Arguments
- guiElement: The gui element in which you want to retrieve the alpha of.
Returns
This function returns a positive integer in between 0 and 1 of the gui element's current alpha, or false if it could not be retrieved.
Example
This example provides a fadeElement function, which fades roughly over a period of 4 seconds. The user may fade in or fade out an element
function fadeElement ( guiElement, state ) if state == "out" then --if the user specifies he wants to fade out an element local currentAlpha = guiGetAlpha ( guiElement )--get the current alpha local newAlpha = currentAlpha - 0.4 --set the alpha to 4 less (more transparent) --ensure that the alpha is not below 0, if it is, set it to 0 if newAlpha < 0 then newAlpha = 0 end --set the new alpha guiSetAlpha ( guiElement, newAlpha ) --if the new alpha is not completely invisible already if newAlpha ~= 0 then --call this function to fade out some more 50ms later setTimer ( fadeElement, 50, 1, guiElement, state ) end elseif state == "in" then --else, if the user specifies he wants to fade out an element local currentAlpha = guiGetAlpha ( guiElement )--get the current alpha local newAlpha = currentAlpha + 0.4 --set the alpha to 4 more(less transparent) --ensure that the alpha is not above 255, if it is, set it to 255 if newAlpha > 1 then newAlpha = 1 end --set the new alpha guiSetAlpha ( guiElement, newAlpha ) --if the new alpha is not completely opaque already if newAlpha ~= 1 then --call this function to fade in some more 50ms later setTimer ( fadeElement, 50, 1, guiElement, state ) end end end
Edited by JR10, was wrong, the Alpha is a float between 0 and 1
See Also
General functions
- guiBringToFront
- getChatboxLayout
- getChatboxCharacterLimit
- guiCreateFont
- guiBlur
- guiFocus
- guiGetAlpha
- guiGetCursorType
- guiGetEnabled
- guiGetFont
- guiGetInputEnabled
- guiGetInputMode
- guiGetPosition
- guiGetProperties
- guiGetProperty
- guiGetScreenSize
- guiGetSize
- guiGetText
- guiGetVisible
- guiMoveToBack
- guiSetAlpha
- guiSetEnabled
- guiSetFont
- guiSetInputEnabled
- guiSetInputMode
- guiSetPosition
- guiSetProperty
- guiSetSize
- guiSetText
- guiSetVisible
- isChatBoxInputActive
- isConsoleActive
- isDebugViewActive
- isMainMenuActive
- isMTAWindowActive
- isTransferBoxActive
- setChatboxCharacterLimit
- setDebugViewActive
Browsers
Buttons
Checkboxes
Comboboxes
- guiCreateComboBox
- guiComboBoxAddItem
- guiComboBoxClear
- guiComboBoxGetItemCount
- guiComboBoxGetItemText
- guiComboBoxGetSelected
- guiComboBoxIsOpen
- guiComboBoxRemoveItem
- guiComboBoxSetItemText
- guiComboBoxSetOpen
- guiComboBoxSetSelected
Edit Boxes
- guiCreateEdit
- guiEditGetCaretIndex
- guiEditGetMaxLength
- guiEditIsMasked
- guiEditIsReadOnly
- guiEditSetCaretIndex
- guiEditSetMasked
- guiEditSetMaxLength
- guiEditSetReadOnly
Gridlists
- guiCreateGridList
- guiGridListAddColumn
- guiGridListAddRow
- guiGridListAutoSizeColumn
- guiGridListClear
- guiGridListGetColumnCount
- guiGridListGetColumnTitle
- guiGridListGetColumnWidth
- guiGridListGetHorizontalScrollPosition
- guiGridListGetItemColor
- guiGridListGetItemData
- guiGridListGetItemText
- guiGridListGetRowCount
- guiGridListGetSelectedCount
- guiGridListGetSelectedItem
- guiGridListGetSelectedItems
- guiGridListGetSelectionMode
- guiGridListIsSortingEnabled
- guiGridListGetVerticalScrollPosition
- guiGridListInsertRowAfter
- guiGridListRemoveColumn
- guiGridListRemoveRow
- guiGridListSetColumnTitle
- guiGridListSetColumnWidth
- guiGridListSetHorizontalScrollPosition
- guiGridListSetItemColor
- guiGridListSetItemData
- guiGridListSetItemText
- guiGridListSetScrollBars
- guiGridListSetSelectedItem
- guiGridListSetSelectionMode
- guiGridListSetSortingEnabled
- guiGridListSetVerticalScrollPosition
Memos
- guiCreateMemo
- guiMemoGetCaretIndex
- guiMemoGetVerticalScrollPosition
- guiMemoSetVerticalScrollPosition
- guiMemoIsReadOnly
- guiMemoSetCaretIndex
- guiMemoSetReadOnly
Progressbars
Radio Buttons
Scrollbars
Scrollpanes
- guiCreateScrollPane
- guiScrollPaneGetHorizontalScrollPosition
- guiScrollPaneGetVerticalScrollPosition
- guiScrollPaneSetHorizontalScrollPosition
- guiScrollPaneSetScrollBars
- guiScrollPaneSetVerticalScrollPosition
Static Images
Tab Panels
Tabs
Text Labels
- guiCreateLabel
- guiLabelGetColor
- guiLabelGetFontHeight
- guiLabelGetTextExtent
- guiLabelSetColor
- guiLabelSetHorizontalAlign
- guiLabelSetVerticalAlign