Print out all named colors

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Print out all named colors

Post by Vadi »

lua showColors()
ShowColors.png

ali0sha
Posts: 4
Joined: Tue Jun 30, 2009 7:25 am

Re: Print out all named colors

Post by ali0sha »

Try this, it discards all colours including capitals (because they're duplicates of colours containing _) and prints them in nice columns. Change the if wrap==5 to some other value to change how many columns on the page.

Oh, and please, if you can make this shorter and nicer, post a reply.

Edit: I removed about a third of the lines.

Code: Select all

wrap=0
for i,v in pairs(color_table) do
   if string.find(i,'%u') == nil then
      fg(i)
      echo (i .. string.rep(" ",22-string.len(i)))
      resetFormat()
      if wrap == 5 then 
         wrap = 0
         echo("\n")
      else 
         wrap = wrap + 1 
      end
   end
end

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Print out all named colors

Post by Vadi »

I've actually submitted a patch to get rid of the duplicate colors, its not in yet. But that is nicer.

Janalon
Posts: 11
Joined: Mon Apr 20, 2009 8:53 pm

Re: Print out all named colors

Post by Janalon »

Thanks, I was actually looking for this list.

User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

Re: Print out all named colors

Post by demonnic »

while having the script is nice and all, I thought I'd post up a new, formatted, duplicate removed color card in image format. Because it can be nice to have something to stare out without having the mud client open while making your color choices. So here it is. Again, if you click on it you'll get a non-squished version.

color-table.png


I think I'm going to work on one that uses the bg color to show the color, and keeps the txt in black. Make it easier to see the actual colors.


Edited: I think this has the snapshot the way I want it. finally.

Denarii
Posts: 111
Joined: Thu Dec 03, 2009 10:54 pm

Re: Print out all named colors

Post by Denarii »

I already have a function for this going into the next version. It's showColors(number_of_columns), it defaults to 3 columns.
Attachments
showcolors.png

User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

Re: Print out all named colors

Post by demonnic »

You rock, I won't reinvent the wheel then =)


can't wait for the new version, now. heh


Is it in the luaglobal in git head? <ponders compiling>

ETA: did you hardcode all of that, or check some values in the R,G,B or hex to determine if the txt should be white or black? either way, spiffy

Denarii
Posts: 111
Joined: Thu Dec 03, 2009 10:54 pm

Re: Print out all named colors

Post by Denarii »

This is the function, and no.. the LuaGlobal in git head is really old, but if you want I can send you my current version:

Code: Select all

function showColors(...)
	local cols = ... or 3
	local i = 1
	for k,v in pairs(color_table) do
		local fg
		local luminosity = (0.2126 * ((v[1]/255)^2.2)) + (0.7152 * ((v[2]/255)^2.2)) + (0.0722 * ((v[3]/255)^2.2))
		if luminosity > 0.5 then
			fg = {0,0,0}
		else
			fg = {255,255,255}
		end
		hecho("|c"..RGB2Hex(unpack(fg))..","..RGB2Hex(unpack(v))..k..string.rep(" ", 23-k:len()))
		echo"  "
		if i == cols then 
			echo"\n"
			i = 1
		else 
			i = i + 1
		end
	end
end

User avatar
Alexander Divine
Posts: 65
Joined: Mon Dec 21, 2009 7:01 pm

Re: Print out all named colors

Post by Alexander Divine »

Does anyone have a list of which of Mudlet's colors correspond with IRE's 16 colors? I found a few perfect matches, but the rest of my colors are out of whack.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Print out all named colors

Post by Vadi »

None because colors can be user-defined in the settings dialog.

I believe heiko said there will be lua variables which contain the values, though. Or you could use the ansi color codes.

Post Reply