help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: function to get inverse color name?


From: Emanuel Berg
Subject: Re: function to get inverse color name?
Date: Thu, 24 Apr 2014 19:51:26 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

unfrostedpoptart <david@therogoffs.com> writes:

> Does anyone have a function that takes a named color
> (e.g. "Red") and returns the inverse?  I guess it
> would convert the name to RRGGBB, subtract each 8-bit
> value from 256, and then convert back to a name.

Interesting question! I would start out examining
`color-name-to-rgb' - you want the inverse of that, so
check out how they did it (in color.el).

Try it: (color-name-to-rgb "white")

Second, check out color.el in general to see what's
there that can help you.

Third, if everything fails, check out the output of

(list-colors-display)

As you see, strings to the left, hex code to the
right. You have to match your colors with the right
column, and then pick the string to the left.

Because you intend to process the color codes, to
acquire the inverse, perhaps you will end up with
colors that aren't defined. I don't know how that will
work out - will it produce an error (on assigning the
color), or will Emacs pick "the closest"? If Emacs does
that, you can reuse the same function. If not, you'll
have to write that yourself as well - linear algebra
and vectors in the color cube... Yikes!

Doing this manually is an option, of course :)

And don't be too sure "the inverse" will actually
produce the perceived inverse result.

Good luck! And report back what you learn on the way...

-- 
underground experts united:
http://user.it.uu.se/~embe8573


reply via email to

[Prev in Thread] Current Thread [Next in Thread]