[Development] Blip colour id to RGB

!! This forum post is for developers only !!

Hey, for reasons that would take too long to explain, I store blip colour ids in my database, but I need colour-matched markers at the world coordinates of the associated blips, so I wrote this table, which contains the blip id as the index and the associated rgb code to the right. note that in a for loop:
r = v[1]
g = v[2]
b = v[3].

IMPORTANT

I am publishing this because no one should ever have to do this again!
Please ignore the names of the colours as a comment next to it, at a certain point (id 35) I left out a number and therefore the order is wrong from there on!

List of Blip colours

Code (the function to get it is under the colour table)

Config = {}
Config.BlipToRgb = {
	["0"] = {254, 254, 254}, -- white
	["1"] = {224, 50, 50}, -- red
	["2"] = {113, 203, 113}, -- green
	["3"] = {93, 182, 229}, -- blue
	["4"] = {254, 254, 254}, -- white
	["5"] = {238, 198, 78}, -- yellow
	["6"] = {194, 80, 80}, -- light red
	["7"] = {156, 110, 175}, -- violet
	["8"] = {254, 122, 195}, -- pink
	["9"] = {245, 157, 121}, -- light orange
	["10"] = {177, 143, 131}, -- light brown
	["11"] = {141, 206, 167}, -- light green
	["12"] = {112, 168, 174}, -- light blue
	["13"] = {211, 209, 231}, -- light purple
	["14"] = {143, 126, 152}, -- dark purple
	["15"] = {106, 196, 191}, -- cyan
	["16"] = {213, 195, 152}, -- light yellow
	["17"] = {234, 142, 80}, -- orange
	["18"] = {151, 202, 233}, -- light blue
	["19"] = {178, 98, 135}, -- dark pink
	["20"] = {143, 141, 121}, -- dark yellow
	["21"] = {166, 117, 94}, -- dark orange
	["22"] = {175, 168, 168}, -- light gray
	["23"] = {231, 141, 154}, -- light pink
	["24"] = {187, 214, 91}, -- lemon green
	["25"] = {12, 123, 86}, -- forest green
	["26"] = {122, 195, 254}, -- electric blue
	["27"] = {171, 60, 230}, -- bright purple
	["28"] = {205, 168, 12}, -- dark yellow
	["29"] = {69, 97, 171}, -- dark blue
	["30"] = {41, 165, 184}, -- dark cyan
	["31"] = {184, 155, 123}, -- light brown
	["32"] = {200, 224, 254}, -- light blue
	["33"] = {240, 240, 150}, -- light yellow
	["34"] = {237, 140, 161}, -- light pink
	["35"] = {249, 138, 138}, -- beige -- from here it's wrong 36 is actually: beige
	["36"] = {251, 238, 165}, -- white
	["37"] = {254, 254, 254}, -- blue
	["38"] = {44, 109, 184}, -- light gray
	["39"] = {154, 154, 154}, -- dark gray
	["40"] = {76, 76, 76}, -- pink red
	["41"] = {242, 157, 157}, -- blue
	["42"] = {108, 183, 214}, -- light green
	["43"] = {175, 237, 174}, -- light orange
	["44"] = {255, 167, 95}, -- white
	["45"] = {241, 241, 241}, -- gold
	["46"] = {236, 240, 41}, -- orange
	["47"] = {255, 154, 24}, -- brilliant rose
	["48"] = {246, 68, 165}, -- red
	["49"] = {224, 58, 58}, -- blue
	["50"] = {138, 109, 227}, -- medium purple
	["51"] = {255, 139, 92}, -- salmon
	["52"] = {65, 108, 65}, -- dark green
	["53"] = {179, 221, 243}, -- blizzard blue
	["54"] = {58, 100, 121}, -- oracle blue
	["55"] = {160, 160, 160}, -- silver
	["56"] = {132, 114, 50}, -- brown
	["57"] = {101, 185, 231}, -- blue
	["58"] = {75, 65, 117}, -- east bay
	["59"] = {225, 59, 59}, -- red
	["60"] = {240, 203, 88}, -- yellow orange
	["61"] = {205, 63, 152}, -- mulberry pink
	["62"] = {207, 207, 207}, -- alto gray
	["63"] = {39, 106, 159}, -- jerry bean blue
	["64"] = {216, 123, 27}, -- dark orange
	["65"] = {142, 131, 147}, -- mamba
	["66"] = {240, 203, 87}, -- yellow orange
	["67"] = {101, 185, 231}, -- blue
	["68"] = {101, 185, 231}, -- blue
	["69"] = {121, 205, 121}, -- green
	["70"] = {239, 202, 87}, -- yellow orange
	["71"] = {239, 202, 87}, -- yellow orange
	["72"] = {61, 61, 61}, -- transparent black
	["73"] = {239, 202, 87}, -- yellow orange
	["74"] = {101, 185, 231}, -- blue
	["75"] = {224, 50, 50}, -- red
	["76"] = {120, 35, 35}, -- deep red
	["77"] = {101, 185, 231}, -- blue
	["78"] = {58, 100, 121}, -- oracle blue
	["79"] = {224, 50, 50}, -- red
	["80"] = {101, 185, 231}, -- transparent blue
	["81"] = {242, 164, 12}, -- orange
	["82"] = {164, 204, 170}, -- light green
	["83"] = {168, 84, 242}, -- purple
	["84"] = {101, 185, 231}, -- blue
	["85"] = {61, 61, 61}, -- transparent black
}

function GetRgbFromBlipColor(id)
	for k, v in pairs(Config.BlipToRgb) do
		if tonumber(k) == id then
			return v
		end
	end
end

Usage

local rgb = GetRgbFromBlipColor(0) -- this returns white : 254, 254, 254
-- actually an bad example --
rgb[1] = 254,
rgb[2] = 254,
rgb[3] = 254,
4 Likes
local blip = blip --GetWaypointBlipEnumId(8)
local blipcolor = GetBlipHudColour(blip) -- or GetBlipColour(blip) --not the same
local r,g,b,a = GetHudColour(blipcolor)
print(json.encode({r,g,b,a}))
print(r,g,b,a)

20220514143302

1 Like

Thanks for sharing your code snippet. I didn’t know that it’s possible to get the rgba from a blip this way. :+1:

It makes me a little bit sad that I wasted my time :smile:

1 Like

I think it is a good job. You did not wasted your time actually.

1 Like

I just tried it and it thinks purple is red?
(the marker should actually have the same colour as the blip area (before that it still worked, so it had the right colour)

Here is the code I used:

function GetRgbFromBlip(id)
	-- old method -- ;(
	-- for k, v in pairs(Config.BlipToRgb) do
	-- 	if tonumber(k) == id then
	-- 		return v
	-- 	end
	-- end
	local rgb = {}
	local r,g,b,a = GetHudColour(id)
	rgb[1], rgb[2], rgb[3], rgb[4] = r, g, b, a

	return rgb
end

https://cdn.discordapp.com/attachments/919964850657050676/975039716535697488/unknown.png

1 Like

um…try this

function GetRgbFromBlip(id)
	local blip = id
local blipcolor = GetBlipHudColour(blip) -- or GetBlipColour(blip) --not the same
local r,g,b,a = GetHudColour(blipcolor)
return {r,g,b,a}
end

the parameter id is the colour id of the blip in this case, and not the actual blip.

I think that is the point to use your lib

1 Like

yesir!
:point_left: :point_left: