GuiLabelGetColor: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 17: Line 17:


==Example==
==Example==
This example creates a label in the center of the screen and sets the color, then outputs the color.
<syntaxhighlight lang="lua">local pLabel = guiCreateLabel( 0.5, 0.5, 0.5, 0.5, 'Text', true )
<syntaxhighlight lang="lua">local label = guiCreateLabel(0,0,10,10,"LABEL COLOR!!!",false)
guiLabelSetColor( pLabel, math.random( 0, 255 ), math.random( 0, 255 ), math.random( 0, 255 ) )
guiLabelSetColor ( label, math.random(0, 255), math.random(0, 255), math.random(0, 255) )
 
local r,g,b = guiLabelGetColor ( label )
addCommandHandler( 'get_color_label',
outputChatBox("The label color is R:"..r.." G:"..g.." B:"..b.." .")
    function()
setTimer(destroyElement,10000,1,label)
        local iR, iG, iB = guiLabelGetColor( pLabel )
        outputChatBox( ( 'Label color is r = %d, g = %d, b = %d' ):format( iR, iG, iB ) )
    end
)</syntaxhighlight>
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{GUI functions}}
{{GUI functions}}

Revision as of 15:05, 16 February 2013

ADDED/UPDATED IN VERSION 1.3.1 r4670:

This function gets the color of a label.

Syntax

int int int guiLabelGetColor ( gui-element theLabel )

Required Arguments

  • theLabel: The label to get color.

Returns

Returns three int values, representing the amount of red, green, blue if successful. false otherwise.

Example

local pLabel = guiCreateLabel( 0.5, 0.5, 0.5, 0.5, 'Text', true )
guiLabelSetColor( pLabel, math.random( 0, 255 ), math.random( 0, 255 ), math.random( 0, 255 ) )

addCommandHandler( 'get_color_label', 
    function()
        local iR, iG, iB = guiLabelGetColor( pLabel )
        outputChatBox( ( 'Label color is r = %d, g = %d, b = %d' ):format( iR, iG, iB ) )
    end
)

</syntaxhighlight>

See Also

General functions

Browsers

Buttons

Checkboxes

Comboboxes

Edit Boxes

Gridlists

Memos

Progressbars

Radio Buttons

Scrollbars

Scrollpanes

Static Images

Tab Panels

Tabs

Text Labels

Windows