DgsLabelGetColor: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 5: Line 5:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int, int, int dgsLabelGetColor ( element theLabel [, bool notSplit = false ] )
int, int, int, int dgsLabelGetColor ( element theLabel [, bool notSplit = false ] )
</syntaxhighlight>  
</syntaxhighlight>  


Line 15: Line 15:
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 true, returns one ''int'' value, representing the color of the label if successful. ''false'' otherwise.


If argument 'notSplit' passed is 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==

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