TextItemSetColor: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(Remove spaces) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
This function | {{Server function}} | ||
This function sets the color of a text item. | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool textItemSetColor ( textitem | bool textItemSetColor ( textitem theTextItem, int r, int g, int b, int a ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*''' | *'''theTextItem:''' The textitem you wish to set the color of. | ||
*'''red:''' The amount of red in the | *'''red:''' The amount of red in the text item's color (0 - 255). | ||
*'''green:''' The amount of green in the | *'''green:''' The amount of green in the text item's color (0 - 255). | ||
*'''blue:''' The amount of blue in the | *'''blue:''' The amount of blue in the text item's color (0 - 255). | ||
*'''alpha:''' The amount of alpha in the | *'''alpha:''' The amount of alpha in the text item's color (0 - 255). Alpha decides transparency where 255 is opaque and 0 is transparent. | ||
===Returns=== | ===Returns=== | ||
Line 19: | Line 19: | ||
==Example== | ==Example== | ||
This example gets the color of a textitem named ' | This example gets the color of a textitem named 'theTextItem' and if it is green, changes it to blue. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
r,g,b,a = textItemGetColor ( | r,g,b,a = textItemGetColor ( theTextItem ) -- get the text color and store it in the variables 'r', 'g', 'b' and 'a' | ||
if ( r == 0 ) and ( g == 255 ) and ( b == 0 ) then | if ( r == 0 ) and ( g == 255 ) and ( b == 0 ) then -- if the color is green | ||
textItemSetColor ( | textItemSetColor ( theTextItem, 0, 0, 255, 255 ) -- set it to blue | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> |
Latest revision as of 21:15, 29 October 2023
This function sets the color of a text item.
Syntax
bool textItemSetColor ( textitem theTextItem, int r, int g, int b, int a )
Required Arguments
- theTextItem: The textitem you wish to set the color of.
- red: The amount of red in the text item's color (0 - 255).
- green: The amount of green in the text item's color (0 - 255).
- blue: The amount of blue in the text item's color (0 - 255).
- alpha: The amount of alpha in the text item's color (0 - 255). Alpha decides transparency where 255 is opaque and 0 is transparent.
Returns
Returns true if the color was successfully set, false otherwise.
Example
This example gets the color of a textitem named 'theTextItem' and if it is green, changes it to blue.
r,g,b,a = textItemGetColor ( theTextItem ) -- get the text color and store it in the variables 'r', 'g', 'b' and 'a' if ( r == 0 ) and ( g == 255 ) and ( b == 0 ) then -- if the color is green textItemSetColor ( theTextItem, 0, 0, 255, 255 ) -- set it to blue end
See Also
- textCreateDisplay
- textCreateTextItem
- textDestroyDisplay
- textDestroyTextItem
- textDisplayAddObserver
- textDisplayAddText
- textDisplayGetObservers
- textDisplayIsObserver
- textDisplayRemoveObserver
- textDisplayRemoveText
- textItemGetColor
- textItemGetPosition
- textItemGetPriority
- textItemGetScale
- textItemGetText
- textItemSetColor
- textItemSetPosition
- textItemSetPriority
- textItemSetScale
- textItemSetText