Garry's Mod Wiki

ColorAlpha

  table ColorAlpha( table color, number alpha )

Description

Returns a new Color with the RGB components of the given Color and the alpha value specified.

Arguments

1 table color
The Color from which to take RGB values. This color will not be modified.
2 number alpha
The new alpha value, a number between 0 and 255. Values above 255 will be clamped.

Returns

1 table
The new Color with the modified alpha value

Example

local red = Color( 255, 0, 0, 255 ) local red2 = ColorAlpha( red, 125 ) print( red.r, red.g, red.b, red.a ) print( red2.r, red2.g, red2.b, red2.a )
Output:
255 0 0 255 255 0 0 125