* function to get inverse color name?
@ 2014-04-24 3:03 unfrostedpoptart
2014-04-24 13:44 ` Drew Adams
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: unfrostedpoptart @ 2014-04-24 3:03 UTC (permalink / raw)
To: help-gnu-emacs
Hi all.
I'm doing a major overhaul of my emacs 24 init.el files. I'm trying to convert a lot of faces from dark to light to set up alternate themes. I know I can just invert everything with invert-all-faces, but I want to do them individually and have the correct name.
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.
Thanks for any help and/or pointers to useful functions!
David
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: function to get inverse color name?
2014-04-24 3:03 function to get inverse color name? unfrostedpoptart
@ 2014-04-24 13:44 ` Drew Adams
2014-04-24 18:08 ` David Rogoff
2014-04-24 17:51 ` Emanuel Berg
2014-04-24 22:58 ` Emanuel Berg
2 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2014-04-24 13:44 UTC (permalink / raw)
To: unfrostedpoptart, help-gnu-emacs
> I'm doing a major overhaul of my emacs 24 init.el files. I'm trying to
> convert a lot of faces from dark to light to set up alternate themes. I
> know I can just invert everything with invert-all-faces, but I want to do
> them individually and have the correct name.
>
> 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.
>
> Thanks for any help and/or pointers to useful functions!
Library hexrgb.el has this (`hexrgb-complement') and many other such
utility functions for colors.
Library palette.el provides a WYSIWYG color palette for working with
colors. In the palette, `~' picks the complement of the current color.
Both libraries are on Emacs Wiki and MELPA:
http://www.emacswiki.org/emacs-en/download/hexrgb.el
http://www.emacswiki.org/emacs-en/download/palette.el
You can see the color palette here:
http://www.emacswiki.org/emacs/ColorPalette
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: function to get inverse color name?
2014-04-24 13:44 ` Drew Adams
@ 2014-04-24 18:08 ` David Rogoff
0 siblings, 0 replies; 5+ messages in thread
From: David Rogoff @ 2014-04-24 18:08 UTC (permalink / raw)
To: Drew Adams; +Cc: help-gnu-emacs
Thanks Drew!
On Apr 24, 2014, at 6:44 AM, Drew Adams <drew.adams@oracle.com> wrote:
>> I'm doing a major overhaul of my emacs 24 init.el files. I'm trying to
>> convert a lot of faces from dark to light to set up alternate themes. I
>> know I can just invert everything with invert-all-faces, but I want to do
>> them individually and have the correct name.
>>
>> 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.
>>
>> Thanks for any help and/or pointers to useful functions!
>
> Library hexrgb.el has this (`hexrgb-complement') and many other such
> utility functions for colors.
>
> Library palette.el provides a WYSIWYG color palette for working with
> colors. In the palette, `~' picks the complement of the current color.
>
> Both libraries are on Emacs Wiki and MELPA:
> http://www.emacswiki.org/emacs-en/download/hexrgb.el
> http://www.emacswiki.org/emacs-en/download/palette.el
>
> You can see the color palette here:
> http://www.emacswiki.org/emacs/ColorPalette
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: function to get inverse color name?
2014-04-24 3:03 function to get inverse color name? unfrostedpoptart
2014-04-24 13:44 ` Drew Adams
@ 2014-04-24 17:51 ` Emanuel Berg
2014-04-24 22:58 ` Emanuel Berg
2 siblings, 0 replies; 5+ messages in thread
From: Emanuel Berg @ 2014-04-24 17:51 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: function to get inverse color name?
2014-04-24 3:03 function to get inverse color name? unfrostedpoptart
2014-04-24 13:44 ` Drew Adams
2014-04-24 17:51 ` Emanuel Berg
@ 2014-04-24 22:58 ` Emanuel Berg
2 siblings, 0 replies; 5+ messages in thread
From: Emanuel Berg @ 2014-04-24 22:58 UTC (permalink / raw)
To: help-gnu-emacs
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.
;; Try this:
;; "#FFFFFF" is white, so this will produce - "black"
(let ((color (color-values (color-complement-hex "#FFFFFF"))))
(dolist (c (tty-color-alist))
(if (eq color (cddr c)) (return (car c))) ))
--
underground experts united:
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-04-24 22:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-24 3:03 function to get inverse color name? unfrostedpoptart
2014-04-24 13:44 ` Drew Adams
2014-04-24 18:08 ` David Rogoff
2014-04-24 17:51 ` Emanuel Berg
2014-04-24 22:58 ` Emanuel Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).