DgsLabelSetColor: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(15 intermediate revisions by the same user not shown)
Line 2: Line 2:
__NOTOC__
__NOTOC__
<!-- Describe in plain english what this function does. Don't go into details, just give an overview -->
<!-- Describe in plain english what this function does. Don't go into details, just give an overview -->
This function allows you to set the color of a GUI label.
This function allows you to set the color of a DGS label.


==Syntax 1==  
==Syntax==  
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool dgsLabelSetColor ( element theElement, int red, int green, int blue, int alpha )
bool dgsLabelSetColor ( element theElement, int red, int green, int blue, int alpha )
Line 11: Line 10:


===Required Arguments===  
===Required Arguments===  
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type -->
*'''theElement:''' The label to be changed.
*'''theElement:''' The label to be changed.
*'''red:''' An integer specifying the amount of red (0 to 255).
*'''red:''' An integer specifying the amount of red (0 to 255).
*'''green:''' An integer specifying the amount of green (0 to 255). '''(If you pass "true" into this argument, see syntax 2 )'''
*'''green:''' An integer specifying the amount of green (0 to 255). '''( If you pass "true" into this argument, see Syntax 2. )'''
*'''blue:''' An integer specifying the amount of blue (0 to 255).
*'''blue:''' An integer specifying the amount of blue (0 to 255).
*'''alpha:''' An integer specifying the amount of alpha (0 to 255).
*'''alpha:''' An integer specifying the amount of alpha (0 to 255).


===Returns===
===Returns===
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check -->
Returns ''true'' if the the color of the dgs label was successfully changed, ''false'' otherwise.
Returns ''true'' if the the color of the gui label was successfully changed, ''false'' otherwise.


==Syntax 2==  
==Example==  
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd -->
This example creates a label with text "Hello World!" and sets it to a random color.
<syntaxhighlight lang="lua">
DGS = exports.dgs
local myLabel = DGS:dgsCreateLabel ( 0.45, 0.48, 0.2, 0.5, "Hello world", true )
DGS:dgsLabelSetColor ( myLabel, math.random(0, 255), math.random(0, 255), math.random(0, 255), 255 )</syntaxhighlight>
 
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool dgsLabelSetColor ( element theElement, int color, bool notSplitColor )
bool dgsLabelSetColor ( element theElement, int color, bool notSplitColor )
Line 29: Line 32:


===Required Arguments===  
===Required Arguments===  
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type -->
*'''theElement:''' The label to be changed.
*'''theElement:''' The label to be changed.
*'''color:''' An integer of the color of the text of the label.
*'''color:''' An integer of the color of the text of the label.
*'''notSplitColor:''' A bool of whether the color argument is splited or not. '''( This argument must be true if you use this syntax! )'''
*'''notSplitColor:''' A bool of whether the color argument is split or not. '''( This argument must be true if you use this syntax! )'''


===Returns===
===Returns===
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check -->
Returns ''true'' if the the color of the dgs label was successfully changed, ''false'' otherwise.
Returns ''true'' if the the color of the gui label was successfully changed, ''false'' otherwise.


==Example==  
==Example==  
This example creates a label with text "Hello World!" and sets it to a random color.
This example creates a label with text "Hello World!" and sets it to a random color.
<syntaxhighlight lang="lua">local myLabel = guiCreateLabel ( 0.45, 0.48, 0.2, 0.5, "Hello world", true )
<syntaxhighlight lang="lua">
DGS = exports.dgs
DGS = exports.dgs
DGS:dgsDxLabelSetColor ( myLabel, math.random(0, 255), math.random(0, 255), math.random(0, 255) )</syntaxhighlight>
local myLabel = DGS:dgsCreateLabel ( 0.45, 0.48, 0.2, 0.5, "Hello world", true )
DGS:dgsLabelSetColor ( myLabel, tocolor(math.random(0, 255), math.random(0, 255), math.random(0, 255), 255 ) ,true )</syntaxhighlight>


==See Also==
==See Also==
{{DGSFUNCTIONS}}
{{DGSFUNCTIONS}}

Latest revision as of 19:15, 16 January 2021

This function allows you to set the color of a DGS label.

Syntax

bool dgsLabelSetColor ( element theElement, int red, int green, int blue, int alpha )

Required Arguments

  • theElement: The label to be changed.
  • red: An integer specifying the amount of red (0 to 255).
  • green: An integer specifying the amount of green (0 to 255). ( If you pass "true" into this argument, see Syntax 2. )
  • blue: An integer specifying the amount of blue (0 to 255).
  • alpha: An integer specifying the amount of alpha (0 to 255).

Returns

Returns true if the the color of the dgs label was successfully changed, false otherwise.

Example

This example creates a label with text "Hello World!" and sets it to a random color.

DGS = exports.dgs
local myLabel = DGS:dgsCreateLabel ( 0.45, 0.48, 0.2, 0.5, "Hello world", true )
DGS:dgsLabelSetColor ( myLabel, math.random(0, 255), math.random(0, 255), math.random(0, 255), 255 )

Syntax

bool dgsLabelSetColor ( element theElement, int color, bool notSplitColor )

Required Arguments

  • theElement: The label to be changed.
  • color: An integer of the color of the text of the label.
  • notSplitColor: A bool of whether the color argument is split or not. ( This argument must be true if you use this syntax! )

Returns

Returns true if the the color of the dgs label was successfully changed, false otherwise.

Example

This example creates a label with text "Hello World!" and sets it to a random color.

DGS = exports.dgs
local myLabel = DGS:dgsCreateLabel ( 0.45, 0.48, 0.2, 0.5, "Hello world", true )
DGS:dgsLabelSetColor ( myLabel, tocolor(math.random(0, 255), math.random(0, 255), math.random(0, 255), 255 ) ,true )

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