[Top][All Lists]

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

bug#4033: 23.1; list-colors-display is misleading

From: Drew Adams
Subject: bug#4033: 23.1; list-colors-display is misleading
Date: Tue, 4 Aug 2009 19:25:26 -0700

> > I have had at least one user state that he thought that, since the
> > form shown is #RRGGBB, his colors had only that granularity.  IOW,
> > even if one's system allows colors of the form #RRRRGGGGBBBB (more
> > colors), the color names are translated to hex strings of the form
> > #RRGGBB (fewer colors).
> Could you show a formula that calculates the color granularity?
> We could use it to print colors in the short format #RRGGBB
> for the smaller color space and #RRRRGGGGBBBB otherwise.

What about something like this:

(defun rgb-color-format-for-display ()
  (let ((ncolors  (display-color-cells (selected-frame)))
        (exp      0))
    (while (> (lsh ncolors (- exp)) 1) (setq exp  (1+ exp)))
    (setq exp  (/ exp 12))
    (format "#%%0%dx%%0%dx%%0%dx" exp exp exp)))

For 16777216 colors, that gives #%02x%02x%02x, which seems right.

In `list-colors-print', we would then do this:

(insert (apply 'format (rgb-color-format-for-display)
               (mapcar (lambda (c) (lsh c -8))
                         (color-values (car color)))))

IOW, replace the hard-coded "#%02x%02x%02x" with (rgb-color-format-for-display).

But I guess Jason and Eli are saying that that wouldn't work or wouldn't be
appropriate. It's still not clear to me.

reply via email to

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