unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: function to get inverse color name?
Date: Thu, 24 Apr 2014 19:51:26 +0200	[thread overview]
Message-ID: <87tx9i4nvl.fsf@nl106-137-194.student.uu.se> (raw)
In-Reply-To: 2c7e7b5b-73ec-45ae-9bf5-b638aad861ff@googlegroups.com

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


  parent reply	other threads:[~2014-04-24 17:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2014-04-24 22:58 ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tx9i4nvl.fsf@nl106-137-194.student.uu.se \
    --to=embe8573@student.uu.se \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).