commit a08197334526f4c4c82916d00dd97748e8d4a33a
parent 646f7f64013c195bd1d9a2e0ca542a59c4eee6ff
Author: Robert Russell <robertrussell.72001@gmail.com>
Date: Tue, 20 Sep 2022 10:00:56 -0700
Add temporary color macros
Diffstat:
| A | color.tex | | | 57 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| M | r3tex.tex | | | 5 | +++-- |
2 files changed, 60 insertions(+), 2 deletions(-)
diff --git a/color.tex b/color.tex
@@ -0,0 +1,57 @@
+% TODO: tmp; use attributes instead
+
+% Convert 4 digit hex number #2#3#4#5 to decimal in range [0,1) and store
+% it in #1.
+\def\@hextodec#1#2#3#4#5{%
+ \dimenA="#2#3#4#5sp
+ \edef#1{\decimal\dimenA}%
+}
+
+% if (\pdfoutput undefined) OR (\pdfoutput <= 0)
+\if1\ifx\pdfoutput\@undefined 1\else\ifnum\pdfoutput>0 0\else 1\fi\fi
+ % dvips
+ \def\@colorpush#1{\special{color push #1}}
+ \def\@colorpop{\special{color pop}}
+ \def\@colorset#1{\@colorpush{#1}\aftergroup\@colorpop}
+ \def\Colorrgb#1#2#3{\@colorset{rgb #1 #2 #3}}
+ \def\Colorgrey#1{\@colorset{gray #1}}
+\else
+ % pdfTeX
+ % TODO: make this an event
+ \everyjob={\mathchardef\@colorstackn=\pdfcolorstackinit page {0 g 0 G}}
+ \def\@colorpush#1{\pdfcolorstack\@colorstackn push {#1}}
+ \def\@colorpop{\pdfcolorstack\@colorstackn pop}
+ \def\@colorset#1{\@colorpush{#1}\aftergroup\@colorpop}
+ \def\Colorrgb#1#2#3{\@colorset{#1 #2 #3 rg #1 #2 #3 RG}}
+ \def\Colorgrey#1{\@colorset{#1 g #1 G}}
+\fi
+
+% Basic colors
+\def\Cblack{\Colorgrey{0}}
+\def\Cwhite{\Colorgrey{1}}
+\def\Cred{\Colorrgb {1}{0}{0}}
+\def\Cgreen{\Colorrgb {0}{1}{0}}
+\def\Cblue{\Colorrgb {0}{0}{1}}
+\def\Ccyan{\Colorrgb {0}{1}{1}}
+\def\Cmagenta{\Colorrgb{1}{0}{1}}
+\def\Cyellow{\Colorrgb {1}{1}{0}}
+
+% Arbitrary HTML-style hex colors
+\def\Chex"#1#2#3#4#5#6{%
+ \beggroup
+ \@hextodec\csA#1#2#1#2% red
+ \@hextodec\csB#3#4#3#4% green
+ \@hextodec\csC#5#6#5#6% blue
+ \edef\@{\endgroup\noexpand\Colorrgb{\csA}{\csB}{\csC}}%
+ \@\ignorespaces
+}
+
+% 16 shades of grey
+\def\Cgrey"#1{%
+ \beggroup
+ \@hextodec\csA#1#1#1#1%
+ \edef\@{\endgroup\noexpand\Colorgrey{\csA}}%
+ \@\ignorespaces
+}
+
+\endinput
diff --git a/r3tex.tex b/r3tex.tex
@@ -4,7 +4,7 @@
\input debug % utilities for debugging
\input util
\input queue % queue data structures
-\input loop
+\input control
\input param
\input text
\input math
@@ -13,9 +13,10 @@
% \input section
\input list
% \input verbatim
-% \input hyphen
% \input graphics
+\input color
\input tmpfont % TODO tmp
+\input hyphen
% Libraries:
% pseudocode