* Use 65535 as scale factor for color-values on NS
@ 2020-06-06 9:57 Mattias Engdegård
2020-06-06 11:17 ` Mattias Engdegård
2020-06-06 18:57 ` Alan Third
0 siblings, 2 replies; 4+ messages in thread
From: Mattias Engdegård @ 2020-06-06 9:57 UTC (permalink / raw)
To: Alan Third; +Cc: Emacs developers
[-- Attachment #1: Type: text/plain, Size: 395 bytes --]
Alan, it seems that only NS uses 65280 as scale factor for 'color-values'; all other back-ends use 65535. Do you know if there is any reason for keeping it this way? Otherwise, I propose we change it (see patch).
It is probably just a relic from when colour components were scaled from 8 to 16 bits by multiplication with 256 instead of 257; this seems to have been fixed everywhere else.
[-- Attachment #2: 0001-Use-65535-as-color-values-scale-value-in-the-NS-back.patch --]
[-- Type: application/octet-stream, Size: 2246 bytes --]
From fba2c0d5f93c05db580b3aa7c8eda7a282411796 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Sat, 6 Jun 2020 11:23:48 +0200
Subject: [PATCH] Use 65535 as color-values scale value in the NS backend
* src/nsfns.m (Fxw_color_values): Scale with 65535 instead of 65280, for
uniformity with other backends.
* lisp/faces.el (color-values): Update doc string.
* doc/lispref/frames.texi (Color Names): Update examples.
---
doc/lispref/frames.texi | 6 +++---
lisp/faces.el | 2 +-
src/nsfns.m | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi
index 6bf5db2aa1..966f620558 100644
--- a/doc/lispref/frames.texi
+++ b/doc/lispref/frames.texi
@@ -3975,11 +3975,11 @@ Color Names
(color-values "black")
@result{} (0 0 0)
(color-values "white")
- @result{} (65280 65280 65280)
+ @result{} (65535 65535 65535)
(color-values "red")
- @result{} (65280 0 0)
+ @result{} (65535 0 0)
(color-values "pink")
- @result{} (65280 49152 51968)
+ @result{} (65535 49344 52171)
(color-values "hungry")
@result{} nil
@end example
diff --git a/lisp/faces.el b/lisp/faces.el
index e707f6f4b6..f4a9dedd79 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -1822,7 +1822,7 @@ color-values
string specifying a color's RGB components (e.g. \"#ff12ec\").
Return a list of three integers, (RED GREEN BLUE), each between 0
-and either 65280 or 65535 (the maximum depends on the system).
+and 65535 inclusive.
Use `color-name-to-rgb' if you want RGB floating-point values
normalized to 1.0.
diff --git a/src/nsfns.m b/src/nsfns.m
index 273fb5f759..5e8d572d8f 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -2329,8 +2329,8 @@ Frames are listed from topmost (first) to bottommost (last). */)
[[col colorUsingDefaultColorSpace]
getRed: &red green: &green blue: &blue alpha: &alpha];
unblock_input ();
- return list3i (lrint (red * 65280), lrint (green * 65280),
- lrint (blue * 65280));
+ return list3i (lrint (red * 65335), lrint (green * 65535),
+ lrint (blue * 65535));
}
--
2.21.1 (Apple Git-122.3)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: Use 65535 as scale factor for color-values on NS
2020-06-06 9:57 Use 65535 as scale factor for color-values on NS Mattias Engdegård
@ 2020-06-06 11:17 ` Mattias Engdegård
2020-06-06 18:57 ` Alan Third
1 sibling, 0 replies; 4+ messages in thread
From: Mattias Engdegård @ 2020-06-06 11:17 UTC (permalink / raw)
To: Alan Third; +Cc: Emacs developers
[-- Attachment #1: Type: text/plain, Size: 148 bytes --]
> <0001-Use-65535-as-color-values-scale-value-in-the-NS-back.patch>
That patch contained a typo (65335 instead of 65535); corrected below. Sorry.
[-- Attachment #2: 0001-Use-65535-as-color-values-scale-value-in-the-NS-back.patch --]
[-- Type: application/octet-stream, Size: 2246 bytes --]
From 38a7e4cce4ae9fb807f82e9efb4d6848668ab547 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Sat, 6 Jun 2020 11:23:48 +0200
Subject: [PATCH] Use 65535 as color-values scale value in the NS backend
* src/nsfns.m (Fxw_color_values): Scale with 65535 instead of 65280, for
uniformity with other backends.
* lisp/faces.el (color-values): Update doc string.
* doc/lispref/frames.texi (Color Names): Update examples.
---
doc/lispref/frames.texi | 6 +++---
lisp/faces.el | 2 +-
src/nsfns.m | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi
index 6bf5db2aa1..966f620558 100644
--- a/doc/lispref/frames.texi
+++ b/doc/lispref/frames.texi
@@ -3975,11 +3975,11 @@ Color Names
(color-values "black")
@result{} (0 0 0)
(color-values "white")
- @result{} (65280 65280 65280)
+ @result{} (65535 65535 65535)
(color-values "red")
- @result{} (65280 0 0)
+ @result{} (65535 0 0)
(color-values "pink")
- @result{} (65280 49152 51968)
+ @result{} (65535 49344 52171)
(color-values "hungry")
@result{} nil
@end example
diff --git a/lisp/faces.el b/lisp/faces.el
index e707f6f4b6..f4a9dedd79 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -1822,7 +1822,7 @@ color-values
string specifying a color's RGB components (e.g. \"#ff12ec\").
Return a list of three integers, (RED GREEN BLUE), each between 0
-and either 65280 or 65535 (the maximum depends on the system).
+and 65535 inclusive.
Use `color-name-to-rgb' if you want RGB floating-point values
normalized to 1.0.
diff --git a/src/nsfns.m b/src/nsfns.m
index 273fb5f759..628233ea0d 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -2329,8 +2329,8 @@ Frames are listed from topmost (first) to bottommost (last). */)
[[col colorUsingDefaultColorSpace]
getRed: &red green: &green blue: &blue alpha: &alpha];
unblock_input ();
- return list3i (lrint (red * 65280), lrint (green * 65280),
- lrint (blue * 65280));
+ return list3i (lrint (red * 65535), lrint (green * 65535),
+ lrint (blue * 65535));
}
--
2.21.1 (Apple Git-122.3)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: Use 65535 as scale factor for color-values on NS
2020-06-06 9:57 Use 65535 as scale factor for color-values on NS Mattias Engdegård
2020-06-06 11:17 ` Mattias Engdegård
@ 2020-06-06 18:57 ` Alan Third
2020-06-07 8:39 ` Mattias Engdegård
1 sibling, 1 reply; 4+ messages in thread
From: Alan Third @ 2020-06-06 18:57 UTC (permalink / raw)
To: Mattias Engdegård; +Cc: Emacs developers
On Sat, Jun 06, 2020 at 11:57:03AM +0200, Mattias Engdegård wrote:
> Alan, it seems that only NS uses 65280 as scale factor for
> 'color-values'; all other back-ends use 65535. Do you know if there
> is any reason for keeping it this way? Otherwise, I propose we
> change it (see patch).
>
> It is probably just a relic from when colour components were scaled
> from 8 to 16 bits by multiplication with 256 instead of 257; this
> seems to have been fixed everywhere else.
I'm not aware of any reason for this, and I don't see any immediate
problems with your (second) patch applied.
--
Alan Third
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Use 65535 as scale factor for color-values on NS
2020-06-06 18:57 ` Alan Third
@ 2020-06-07 8:39 ` Mattias Engdegård
0 siblings, 0 replies; 4+ messages in thread
From: Mattias Engdegård @ 2020-06-07 8:39 UTC (permalink / raw)
To: Alan Third; +Cc: Emacs developers
6 juni 2020 kl. 20.57 skrev Alan Third <alan@idiocy.org>:
> I'm not aware of any reason for this, and I don't see any immediate
> problems with your (second) patch applied.
Thank you! Pushed to master.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-06-07 8:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-06 9:57 Use 65535 as scale factor for color-values on NS Mattias Engdegård
2020-06-06 11:17 ` Mattias Engdegård
2020-06-06 18:57 ` Alan Third
2020-06-07 8:39 ` Mattias Engdegård
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).