From e48ff0f87a65d5ed143d429657ff9fe01c7c87cd Mon Sep 17 00:00:00 2001 From: Max <49086429+gucci-on-fleek@users.noreply.github.com> Date: Fri, 28 Jan 2022 14:44:29 -0700 Subject: [PATCH] Support `RGB` and `gray` color models in ConTeXt The `RGB` support was copied from the the Plain TeX definitions, `tex/generic/pgf/utilities/pgfutil-plain.def:29-37`, which is from #772. The `gray` color model now maps to the grayscale and not to `rgb`. Signed-off-by: Max Chernoff <49086429+gucci-on-fleek@users.noreply.github.com> --- doc/generic/pgf/CHANGELOG.md | 2 ++ tex/generic/pgf/utilities/pgfutil-context.def | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/generic/pgf/CHANGELOG.md b/doc/generic/pgf/CHANGELOG.md index 837fd5ff1..12c0f8f20 100644 --- a/doc/generic/pgf/CHANGELOG.md +++ b/doc/generic/pgf/CHANGELOG.md @@ -73,6 +73,7 @@ lot of contributed changes. Thanks to everyone who volunteered their time! - Form-only patterns have no specified color #1122 - Make `graphdrawing` work with `name prefix` and `name suffix` options #1087 - pgfkeys was a bit too relaxed around `\relax` #1132 +- Add `RGB` and `gray` color model support for ConTeXt #1130 ### Changed @@ -95,6 +96,7 @@ lot of contributed changes. Thanks to everyone who volunteered their time! - Jonathan Spratte - Joseph Wright - Mario Frasca +- Max Chernoff - Michael Kuron - Michal Hoftich - muzimuzhi diff --git a/tex/generic/pgf/utilities/pgfutil-context.def b/tex/generic/pgf/utilities/pgfutil-context.def index eddab09ab..66edb0980 100644 --- a/tex/generic/pgf/utilities/pgfutil-context.def +++ b/tex/generic/pgf/utilities/pgfutil-context.def @@ -26,8 +26,17 @@ \def\pgfutil@definecolor#1#2#3{\csname pgfutil@emu@#2\endcsname{#1}#3\@nil} \def\pgfutil@emu@rgb#1#2,#3,#4\@nil{\expandafter\def\csname\string\color@#1\endcsname{\xcolor@{}{}{rgb}{#2,#3,#4}}} -\def\pgfutil@emu@gray#1#2\@nil{\expandafter\def\csname\string\color@#1\endcsname{\xcolor@{}{}{rgb}{#2,#2,#2}}} +\def\pgfutil@emu@gray#1#2\@nil{\expandafter\def\csname\string\color@#1\endcsname{\xcolor@{}{}{gray}{#2}}} \def\pgfutil@emu@cmyk#1#2,#3,#4,#5\@nil{\expandafter\def\csname\string\color@#1\endcsname{\xcolor@{}{}{cmyk}{#2,#3,#4,#5}}} +\def\pgfutil@emu@RGB#1#2,#3,#4\@nil{% + \begingroup + \pgfmathdivide@{#2}{255}\let\pgfutil@emu@RGB@r\pgfmathresult + \pgfmathdivide@{#3}{255}\let\pgfutil@emu@RGB@g\pgfmathresult + \pgfmathdivide@{#4}{255}\let\pgfutil@emu@RGB@b\pgfmathresult + \edef\pgf@marshal{\def\expandafter\noexpand\csname\string\color@#1\endcsname{% + \noexpand\xcolor@{}{}{rgb}{\pgfutil@emu@RGB@r,\pgfutil@emu@RGB@g,\pgfutil@emu@RGB@b}}}% + \expandafter\endgroup\pgf@marshal +} % no need for x colors (users can load it if needed)