This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
MudkipTheEpic's profile picture

List of ComputerCraft Hex Colors

Started by MudkipTheEpic, 18 July 2013 - 09:37 AM
MudkipTheEpic #1
Posted 18 July 2013 - 11:37 AM
Hi! I've seen the list floating around a few times, but I can't seem to find it. Could someone help?

Edit: Found a link if anyone needs it: http://pastebin.com/jcYuPxrA
Edited on 18 July 2013 - 11:24 AM
GravityScore #2
Posted 18 July 2013 - 11:56 AM
Haven't got them in hex format, but I've got the list in RGB.


"0, 0, 0",		 // Black
"179, 49, 44",	 // Red
"59, 81, 26",	  // Green
"81, 48, 26",	  // Brown
"37, 49, 146",	 // Blue
"123, 47, 190",	// Purple
"40, 118, 151",	// Cyan
"153, 153, 153",   // Light gray
"67, 67, 67",	  // Gray
"216, 129, 152",   // Pink
"65, 205, 52",	 // Lime
"222, 222, 108",   // Yellow
"102, 137, 211",   // Light blue
"195, 84, 205",	// Magenta
"235, 136, 68",	// Orange
"255, 255, 255",   // White

(I think this is what you mean by hex colors :P/>)
Grim Reaper #3
Posted 18 July 2013 - 01:11 PM

white	 : 0
orange	: 1
magenta   : 2
lightBlue : 3
yellow	: 4
lime	  : 5
pink	  : 6
gray	  : 7
lightGray : 8
cyan	  : 9
purple	: A
blue	  : B
brown	 : C
green	 : D
red	   : E
black	 : F

Since all of the colors are multiples of two (increasing exponentially :)/>/>/>), you can use a logarithm to find the exponent which two is raised to achieve the color.
The original formula to get the color representation is y = 2x, so you can just use the inverse of that function: x = log2(y).



local function getHexRepresentationOfColor (color)
	return string.format ("%X",
		   math.floor (math.log (color) / math.log (2)))
end

local function getDecimalRepresentationOfColor (hexRepresentation)
    return math.pow (2, tonumber (hexRepresentation, 16))
end
MudkipTheEpic #4
Posted 18 July 2013 - 01:23 PM
Yep, that's what I meant. I just found an API for it when searching around the OpenPeripheral topic if anyone needs it:

http://pastebin.com/jcYuPxrA

Thanks to you all!

Edit: My 500'th post! *throws party*

I AM a maniac for Lua!

XD
Edited on 18 July 2013 - 11:26 AM
BlockDriller #5
Posted 18 July 2013 - 05:26 PM
There is a page on the wiki if you need any more information.

http://computercraft.info/wiki/Colors_(API)
LBPHacker #6
Posted 18 July 2013 - 06:05 PM
There is a page on the wiki if you need any more information.

http://computercraft...ki/Colors_(API)
Nah, there isn't. Or at least not about the RGB codes. By the way, I think when set to text color, black is a bit brighter than when it's set to background color.

Yup, tested it: 0; 0; 0 (#000000) as a background color, 30; 27; 27 (#1E1B1B) as a text color.
EDIT: You gave me an idea. Gonna add those color codes to the wiki.