unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: Yuri Khan <yuri.v.khan@gmail.com>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
	Emacs developers <emacs-devel@gnu.org>
Subject: Re: master 68ae6fa: Improved light/dark colour predicate (bug#41544)
Date: Fri, 12 Jun 2020 17:50:32 +0200	[thread overview]
Message-ID: <93F81C41-E774-4C02-9E9D-5B2CD1F66445@acm.org> (raw)
In-Reply-To: <CAP_d_8X+0KovnU409Ji1qq1mVqaon34qFoWtpmbahqdgyJpYhA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 932 bytes --]

11 juni 2020 kl. 21.22 skrev Yuri Khan <yuri.v.khan@gmail.com>:

> My equipment [...] says that shade of gold in fact
> performs okay in all four scenarios

I have no reason to doubt your observations. Let's try a plebiscite!

                      * * *

Dear Emacs developer or user,

Please load the attached code (any Emacs version), and run M-x contrast-compare with various cutoff values on your favourite system, to find what value is best for readability of the colour names (first column).

Colours with luminance (last column) below the cutoff will be use white text, others black. It is mainly Emacs in graphical (non-TTY) mode that is of interest.

Please reply (to emacs-devel or to me) the following pieces of information:

* the cutoff value you found optimal
* system information: window system, screen, anything you think is relevant
* whether you use a light or dark background in your Emacs


[-- Attachment #2: color-contrast.el --]
[-- Type: application/octet-stream, Size: 1727 bytes --]

;;; -*- lexical-binding: t -*-

(defconst contrast-default-cutoff 0.325)

(defun contrast-compare (cutoff)
  "Compare black and white text on various colours."
  (interactive
   (list (string-to-number
          (read-from-minibuffer "Cutoff value: "
                                (number-to-string contrast-default-cutoff)))))

  (with-current-buffer (get-buffer-create "*Contrast comparison*")
    (erase-buffer)
    (let ((cols nil)
          (seen (make-hash-table :test 'equal)))
      (dolist (name (defined-colors))
        (let ((cv (color-values name)))
          (unless (gethash cv seen)
            (puthash cv cv seen)
            (push (cons cv name) cols))))
      (insert (format "cutoff = %f\n" cutoff))
      (dolist (c (reverse cols))
        (let* ((cv (car c))
               (name (cdr c))
               (hex (apply #'format "#%02x%02x%02x"
                           (mapcar (lambda (x) (/ x 256)) cv)))
               (rgb (mapcar (lambda (x) (/ x 65535.0)) cv))
               (r (expt (nth 0 rgb) 2.2))
               (g (expt (nth 1 rgb) 2.2))
               (b (expt (nth 2 rgb) 2.2))
               (y (+ (* r 0.2126) (* g 0.7152) (* b 0.0722)))
               (fg (if (< y cutoff) "#ffffff" "#000000")))
          (insert
           (propertize
            (format "  %-20.20s  " name)
            'face (list :background name :foreground fg))
           (propertize
            (format " %s " hex)
            'face (list :background name :foreground "#ffffff"))
           (propertize
            (format " %s " hex)
            'face (list :background name :foreground "#000000"))
           (format "  %.5f\n" y)))))
    (let ((pop-up-windows t))
      (display-buffer (current-buffer)))))

  reply	other threads:[~2020-06-12 15:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200610181238.9796.44750@vcs0.savannah.gnu.org>
     [not found] ` <20200610181239.947C4204DF@vcs0.savannah.gnu.org>
2020-06-10 19:20   ` master 68ae6fa: Improved light/dark colour predicate (bug#41544) Stefan Monnier
2020-06-10 19:34     ` Mattias Engdegård
2020-06-10 20:01       ` Stefan Monnier
2020-06-11  5:15     ` Yuri Khan
2020-06-11 16:15       ` Mattias Engdegård
2020-06-11 19:22         ` Yuri Khan
2020-06-12 15:50           ` Mattias Engdegård [this message]
2020-06-12 16:22             ` tomas
2020-06-12 18:36             ` Yuri Khan
2020-06-13 10:55               ` Mattias Engdegård
2020-06-12 19:02             ` Drew Adams
2020-06-12 19:09             ` Stephen Leake
2020-06-18 19:28               ` Mattias Engdegård
2020-06-18 19:35                 ` Drew Adams
2020-06-18 20:04                   ` Mattias Engdegård
2020-06-18 20:32                     ` Drew Adams
2020-06-21  7:51                       ` Mattias Engdegård
2020-06-18 19:40                 ` Basil L. Contovounesios
2020-06-18 19:58                   ` Mattias Engdegård
2020-06-13  4:05             ` Richard Stallman

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=93F81C41-E774-4C02-9E9D-5B2CD1F66445@acm.org \
    --to=mattiase@acm.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=yuri.v.khan@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).