FromColor: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 20: Line 20:
function fromColor(color)
function fromColor(color)
if color then
if color then
local red = bitExtract(color, 0, 8)
local blue = bitExtract(color, 0, 8)
local green = bitExtract(color, 8, 8)
local green = bitExtract(color, 8, 8)
local blue = bitExtract(color, 16, 8)
local red = bitExtract(color, 16, 8)
local alpha = bitExtract(color, 24, 8)
local alpha = bitExtract(color, 24, 8)

Revision as of 21:03, 26 September 2018

This function converts the hexadecimal numbers of the specified colors

Syntax

int fromColor ( color )

Required Arguments

  • color: Values representing colors.

Returns

Returns an array containing colors (red, green, blue)

Example

Click to collapse [-]
Client

The following code inverts the tocolor function.

function fromColor(color)
	if color then
		local blue = bitExtract(color, 0, 8)
		local green = bitExtract(color, 8, 8)
		local red = bitExtract(color, 16, 8)
		local alpha = bitExtract(color, 24, 8)
		
		return { red, green, blue, alpha }
	end
end

See Also