Named Colors

Discussion of the xtools Toolkit

Moderators: Tom, Kukurykus

xbytor

Named Colors

Post by xbytor »

I got tired of messing around with RGB values in my scripts, so I wrote up some support for named colors. The source of the name<->rgb mapping is the X11 rgb.txt file.

Now you can do stuff like:

Code: Select alllayer.textItem.color = Colors.getColor("pale turquoise");

Much better than the alternative.
Larry Ligon

Named Colors

Post by Larry Ligon »

Gives an error on "throwFileError". Does this require your library? You need to specify if it does.

Here is a way to create your own named swatches: bb/viewtopic.php?t=79

Your might want to add this capability to this script.
xbytor

Named Colors

Post by xbytor »

Here's the missing function:

Code: Select allthrowFileError = function(f, msg) {
  if (msg == undefined) msg = '';
  throw msg + '\"' + f + "\": " + f.error + '.';
};


You only need this if you are going to regenerate and replace the color table.

Here is a way to create your own named swatches: ...
Your might want to add this capability to this script.

I rarely use swatches, but this seems like a good addition. I'll add your dynamic swatch population code along with some code for aco file I/O. Then add some UI to tie it all together.

Have you figured out a way to get the color info out of a swatch? I can read it from the aco file, but I'd like to find a way to read it from the runtime.

thanx,
-X
Larry Ligon

Named Colors

Post by Larry Ligon »

I haven't tried to retrieve the color information from the swatches palette using JavaScript. I'll take a look at it.