From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.devel Subject: Re: master 68ae6fa: Improved light/dark colour predicate (bug#41544) Date: Thu, 11 Jun 2020 12:15:03 +0700 Message-ID: References: <20200610181238.9796.44750@vcs0.savannah.gnu.org> <20200610181239.947C4204DF@vcs0.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="63804"; mail-complaints-to="usenet@ciao.gmane.io" Cc: =?UTF-8?Q?Mattias_Engdeg=C3=A5rd?= , Emacs developers To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jun 11 07:16:06 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jjFZO-000GWn-Bx for ged-emacs-devel@m.gmane-mx.org; Thu, 11 Jun 2020 07:16:06 +0200 Original-Received: from localhost ([::1]:43010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjFZN-00085w-DG for ged-emacs-devel@m.gmane-mx.org; Thu, 11 Jun 2020 01:16:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjFYg-0007LZ-Ru for emacs-devel@gnu.org; Thu, 11 Jun 2020 01:15:22 -0400 Original-Received: from mail-ua1-x92a.google.com ([2607:f8b0:4864:20::92a]:44400) by eggs.gnu.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jjFYf-00027e-Qu for emacs-devel@gnu.org; Thu, 11 Jun 2020 01:15:22 -0400 Original-Received: by mail-ua1-x92a.google.com with SMTP id c9so1678773uao.11 for ; Wed, 10 Jun 2020 22:15:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=YhsweI7L6cBCJQtohgB39qbdiE2eBwUax0fNBwFMlGg=; b=LfPfivTUFC6zvctlAnSG3F+r+qOf5yJCLiGBte4/jIV4W0FqfiXNUj1BJ+dGi3Ak34 mAcj42Fbll4j/LlTAJOJGWNxX7RJrb5im74r8HeT3SLPqGzkRY8ZCpPCo8Y79raZ8qiE DyexMyNm9gz3TH5V7BytPwza81PQ8X/uCOtKI6LoFxRs9gKDXTC6edoBd1R5HOQWkyCb GvV21f2OWz5j578vsXTA172YUXX9D4mG3A+Bp5+Wp7Bnzz9bfPgf66LBg4Us9jeOIMCN ZMlvuOGy8OffB148u9QubXn7O8tlUoWgex5q+14TwyQcycAThxSZ0cjBnbgqd1tVnnU6 AKjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=YhsweI7L6cBCJQtohgB39qbdiE2eBwUax0fNBwFMlGg=; b=HOcIh6iKWDI5aocrlboY/w0/wTpMhj4VNYCX1cwI9zDXykkRFw+wNpvkTZq3HNlvch ysp1zGxmz/Zuf7CZwU0RBgeDPIRjJqyIito1u6lHLsGEHP3sWjMZAVbXFgHmlbgs2RHM f2W+5kUZIf8s2YeGkYrjEJ7o/l/6k2UPkMrKgo75fpvBdDcd9eavGcWkScY6AzHozOUt b7Zk8i+Cw6ca5eZ7j/KslUfzhYuPs6JVDRTQWJ3QBhnMTqsC+1Z/RkLH8LvjUNGUaBI+ j564fUnZ1Ar68qZ9MzI3iQmc0NlqG6NJ0gXuFibbRdONfs5pJzNX6F4XUqe/IJTuaa9H DxDQ== X-Gm-Message-State: AOAM532ij9wHnr79rxokSBAPEpZJ5J3XewhzKRJZ5TWAIhVAm5wPbDQs yJ53dUuYmMta1v8ovbqp9AFa5sKASV7Si7YYT+4= X-Google-Smtp-Source: ABdhPJz54iH6ntFTpmPBF1F6BeL0nol361jXlQ6SKJdzOKUqFyNuAe4xyRNk5fI1dSikGaNYK43ETdmF4XJThW5SGwI= X-Received: by 2002:a9f:222a:: with SMTP id 39mr5244636uad.24.1591852515541; Wed, 10 Jun 2020 22:15:15 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::92a; envelope-from=yurivkhan@gmail.com; helo=mail-ua1-x92a.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:252102 Archived-At: On Thu, 11 Jun 2020 at 02:20, Stefan Monnier wro= te: > > +This predicate can be used both for determining a suitable (black or w= hite) > > +contrast colour with RGB as background and as foreground." > > + ;; and compare to a cut-off value determined experimentally. > > + ;; See https://en.wikipedia.org/wiki/Relative_luminance for details. > > + (< y (eval-when-compile (expt 0.6 2.2))))) > > Where does this 0.6 come from? > I don't see it in https://en.wikipedia.org/wiki/Relative_luminance Instead of comparing the relative luminance against an experimentally determined cutoff, why not do the actual calculations of contrast ratio against black and white? The formula for contrast ratio is: C =3D (L1+0.05) / (L2+0.05) [1] where L1 and L2 are relative luminances of the brighter and the darker colo= rs. So contrast against black is (L+0.05) / 0.05 and contrast against white is 1.05 / (L+0.05). Solving for the middle ground L where these give the same result: (L+0.05) / 0.05 =3D 1.05 / (L+0.05) (L+0.05)^2 =3D 1.05 * 0.05 L+0.05 =3D (1.05 * 0.05)^0.5 L =3D (1.05 * 0.05)^0.5 - 0.05 =E2=89=88 0.18 corresponding to a gray aroun= d #767576 Experimentally, I find white and black over #767576 about equally easy to read; over a light gray #cccbcc (L=3D0.6), black is much more readable than white. [1]: https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio