DgsLabelGetColor: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} {{New feature/item|3.0132|1.3.1|4670| This function gets the color of a label. }} ==Syntax== <syntaxhighlight lang="lua"> int int int dgsDxLabe...")
 
No edit summary
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Client function}}
__NOTOC__
__NOTOC__
{{Client function}}
{{New feature/item|3.0132|1.3.1|4670|
This function gets the color of a label.
This function gets the color of a label.
}}


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int int int dgsDxLabelGetColor ( dgs-element theLabel [, bool notSplit = false ] )
int, int, int, int dgsLabelGetColor ( element theLabel [, bool notSplit = false ] )
</syntaxhighlight>  
</syntaxhighlight>  


Line 15: Line 13:


===Returns===
===Returns===
If argument 'notSplit' passed true, returns one ''int'' value, representing the color of the label if successful. ''false'' otherwise.
If argument 'notSplit' passed is true, returns one ''int'' value, representing the color of the label if successful. ''false'' otherwise.
If argument 'notSplit' passed false, returns three ''int'' values, representing the amount of red, green, blue if successful. ''false'' otherwise.
 
If argument 'notSplit' passed is false, returns four ''int'' values, representing the amount of red, green, blue and alpha if successful. ''false'' otherwise.


==Example==
==Example==
<syntaxhighlight lang="lua">local pLabel = guiCreateLabel( 0.5, 0.5, 0.5, 0.5, 'Text', true )
<syntaxhighlight lang="lua">
guiLabelSetColor( pLabel, math.random( 0, 255 ), math.random( 0, 255 ), math.random( 0, 255 ) )
DGS = exports.dgs
local pLabel = DGS:dgsCreateLabel( 0.5, 0.5, 0.5, 0.5, 'Text', true )
DGS:dgsLabelSetColor( pLabel, math.random( 0, 255 ), math.random( 0, 255 ), math.random( 0, 255 ), 255 )


addCommandHandler( 'get_color_label',  
addCommandHandler( 'get_color_label',  
     function()
     function(cmd,notSplit)
         local iR, iG, iB = guiLabelGetColor( pLabel )
        notSplit = notSplit and true or false
        outputChatBox( ( 'Label color is r = %d, g = %d, b = %d' ):format( iR, iG, iB ) )
        if notSplit then
            local color = DGS:dgsLabelGetColor( pLabel, true )
            outputChatBox( 'Label color is '..color )
         else
            local iR, iG, iB = DGS:dgsLabelGetColor( pLabel )
            outputChatBox( ( 'Label color is r = %d, g = %d, b = %d' ):format( iR, iG, iB ) )
        end
     end
     end
)</syntaxhighlight>
)</syntaxhighlight>


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

Latest revision as of 13:42, 4 August 2023

This function gets the color of a label.

Syntax

int, int, int, int dgsLabelGetColor ( element theLabel [, bool notSplit = false ] )

Required Arguments

  • theLabel: The label to get color.
  • notSplit: A bool of whether the color is split into r,g,b,a or not.

Returns

If argument 'notSplit' passed is true, returns one int value, representing the color of the label if successful. false otherwise.

If argument 'notSplit' passed is false, returns four int values, representing the amount of red, green, blue and alpha if successful. false otherwise.

Example

DGS = exports.dgs
local pLabel = DGS:dgsCreateLabel( 0.5, 0.5, 0.5, 0.5, 'Text', true )
DGS:dgsLabelSetColor( pLabel, math.random( 0, 255 ), math.random( 0, 255 ), math.random( 0, 255 ), 255 )

addCommandHandler( 'get_color_label', 
    function(cmd,notSplit)
        notSplit = notSplit and true or false
        if notSplit then
            local color = DGS:dgsLabelGetColor( pLabel, true )
            outputChatBox( 'Label color is '..color )
        else
            local iR, iG, iB = DGS:dgsLabelGetColor( pLabel )
            outputChatBox( ( 'Label color is r = %d, g = %d, b = %d' ):format( iR, iG, iB ) )
        end
    end
)

See Also

Custom Cursor Functions

Multi Language Supports

Animation

3D Element

3D Interface

3D Line

3D Image

3D Text

Browser

Button

Check Box

Combo Box

Custom Renderer

Edit

Detect Area

Drag'N Drop

Grid List

Image

Memo

Menu

Label

Layout

Line

Progress Bar

Radio Button

Scale Pane

Scroll Bar

Scroll Pane

Selector

Style

Switch Button

Tab Panel

Window

Basic Shape Plugins

Circle

Quadrilateral

Rounded Rectangle

Other Plugins

Blur Box

Canvas

Chart

Color Picker

Effect 3D

Gradient

Mask

Media Browser

Nine Slice

Object Preview Supports

Paste Handler

QRCode

Remote Image

Screen Source

SVG

Tooltips