| 1 |
% -*- coding: utf-8 -*- |
| 2 |
\documentclass{article} |
| 3 |
\usepackage[a4paper,margin=1.5cm]{geometry} |
| 4 |
|
| 5 |
\newcommand*{\myversion}{2022D} |
| 6 |
\newcommand*{\mydate}{Version \myversion\ (\the\year-\mylpad\month-\mylpad\day)} |
| 7 |
\newcommand*{\mylpad}[1]{\ifnum#1<10 0\the#1\else\the#1\fi} |
| 8 |
|
| 9 |
\usepackage{ninecolors} |
| 10 |
\usepackage{arev} |
| 11 |
\usepackage{pgffor} |
| 12 |
\usepackage{l3draw} |
| 13 |
\usepackage{hyperref} |
| 14 |
\hypersetup{ |
| 15 |
colorlinks=true, |
| 16 |
urlcolor=blue3, |
| 17 |
} |
| 18 |
|
| 19 |
\setlength{\parindent}{0pt} |
| 20 |
%\setlength{\parskip}{4pt plus 1pt minus 1pt} |
| 21 |
|
| 22 |
\newcommand\NineTestBack{% |
| 23 |
\foreach \l in {1,...,9} |
| 24 |
{ |
| 25 |
\noindent |
| 26 |
\foreach \n in {gray,red,brown,yellow,olive,green,teal,cyan,azure,blue,violet,magenta,purple} |
| 27 |
{% |
| 28 |
\xdef\mycolor{\ifnum \l < 5 white\else black\fi}% |
| 29 |
\colorbox{\n\l}{\color{\mycolor}\strut\n\l}% |
| 30 |
} |
| 31 |
\par |
| 32 |
}} |
| 33 |
|
| 34 |
\newcommand\NineTestFore{% |
| 35 |
\foreach \l in {1,...,9} |
| 36 |
{ |
| 37 |
\noindent |
| 38 |
\foreach \n in {gray,red,brown,yellow,olive,green,teal,cyan,azure,blue,violet,magenta,purple} |
| 39 |
{% |
| 40 |
\xdef\mycolor{\ifnum \l < 5 gray9\else black\fi}% |
| 41 |
\colorbox{\mycolor}{\color{\n\l}\strut\n\l}% |
| 42 |
} |
| 43 |
\par |
| 44 |
}} |
| 45 |
|
| 46 |
\newcommand\NineTestContrast{% |
| 47 |
\colorbox{blue9}{% |
| 48 |
\strut\color{green3}The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. |
| 49 |
} |
| 50 |
\par\nointerlineskip |
| 51 |
\colorbox{green3}{% |
| 52 |
\strut\color{blue9}The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. |
| 53 |
} |
| 54 |
\par\nointerlineskip |
| 55 |
\colorbox{violet9}{% |
| 56 |
\strut\color{brown3}The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. |
| 57 |
} |
| 58 |
\par\nointerlineskip |
| 59 |
\colorbox{brown3}{% |
| 60 |
\strut\color{violet9}The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. |
| 61 |
}} |
| 62 |
|
| 63 |
\newcommand\NineTestSaturation[1]{{% |
| 64 |
\NineColors{saturation=#1} |
| 65 |
\noindent\centering |
| 66 |
\colorbox{white}{\makebox[4em]{\strut #1}}% |
| 67 |
\foreach \n in {red,brown,yellow,olive,green,teal,cyan,azure,blue,violet,magenta,purple} |
| 68 |
{% |
| 69 |
\colorbox{\n5}{\makebox[3em]{\strut\rule[-2ex]{0pt}{5.5ex}TEST}}% |
| 70 |
} |
| 71 |
\par |
| 72 |
}} |
| 73 |
|
| 74 |
\newcommand\NineTestAllSaturations{% |
| 75 |
\NineTestSaturation{high}% |
| 76 |
\NineTestSaturation{medium}% |
| 77 |
\NineTestSaturation{low}% |
| 78 |
} |
| 79 |
|
| 80 |
\ExplSyntaxOn |
| 81 |
|
| 82 |
\cs_generate_variant:Nn \color_fill:n { x } |
| 83 |
\cs_generate_variant:Nn \color_stroke:n { x } |
| 84 |
|
| 85 |
\newcommand\NineTestDraw{ |
| 86 |
\foreach \l [evaluate=\l~as~\m~using~int(10-\l)] in {1,...,9} |
| 87 |
{ |
| 88 |
\noindent |
| 89 |
\foreach \n in {gray,red,brown,yellow,olive,green,teal, |
| 90 |
cyan,azure,blue,violet,magenta,purple} |
| 91 |
{ |
| 92 |
\draw_begin: |
| 93 |
\draw_scope_begin: |
| 94 |
\color_stroke:x { \n\m } |
| 95 |
\color_fill:x { \n\l } |
| 96 |
\draw_path_circle:nn { 0, 0 } { 10pt } |
| 97 |
\draw_path_use_clear:n { stroke, fill } |
| 98 |
\draw_scope_end: |
| 99 |
\draw_end: |
| 100 |
\qquad |
| 101 |
} |
| 102 |
\par |
| 103 |
\vspace*{0.5ex} |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
\ExplSyntaxOff |
| 108 |
|
| 109 |
\begin{document} |
| 110 |
|
| 111 |
\title{\textcolor{blue3}{Ninecolors: Select Colors with Proper WCAG Color Contrast}% |
| 112 |
\footnote{\url{https://github.com/lvjr/ninecolors}}} |
| 113 |
\author{Jianrui Lyu ([email protected]) \\ Nan Geng ([email protected])} |
| 114 |
\date{\mydate} |
| 115 |
\maketitle |
| 116 |
|
| 117 |
\section{LaTeX2 Colors with Medium Saturation} |
| 118 |
|
| 119 |
\textcolor{red4}{Ninecolors} package carefully selects and defines 9 colors for 13 hues each. |
| 120 |
All colors with the same suffix number have equal luminance level. |
| 121 |
Also color black is of level 0, and color white is of level 10. |
| 122 |
|
| 123 |
\bigskip |
| 124 |
|
| 125 |
\NineTestBack |
| 126 |
|
| 127 |
\medskip |
| 128 |
|
| 129 |
\NineTestFore |
| 130 |
|
| 131 |
\bigskip |
| 132 |
|
| 133 |
By simply choosing two colors in the above list, which differ in level by at least 5, |
| 134 |
as foreground and background colors, you will get proper |
| 135 |
\href{https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html}{WCAG Color Contrast}. |
| 136 |
|
| 137 |
\bigskip |
| 138 |
|
| 139 |
\NineTestContrast |
| 140 |
|
| 141 |
\bigskip |
| 142 |
|
| 143 |
If you need to select more contrasting foreground and background colors, which may have other hues, |
| 144 |
you could visit \href{https://lvjr.bitbucket.io/contrast.html}{WCAG Color Contrast Tool} |
| 145 |
page which is designed by the first author. |
| 146 |
|
| 147 |
\newpage |
| 148 |
|
| 149 |
\section{LaTeX2 Colors with Low Saturation} |
| 150 |
|
| 151 |
You can change the saturation of colors by {\color{red3}\verb!\NineColors!} command. |
| 152 |
By default {\color{red3}\verb!saturation=medium!}. |
| 153 |
|
| 154 |
\bigskip |
| 155 |
|
| 156 |
\NineTestAllSaturations |
| 157 |
|
| 158 |
\bigskip |
| 159 |
|
| 160 |
\NineColors{saturation=low} |
| 161 |
Colors in the remaining part of the page have been changed by |
| 162 |
{\color{red3}\verb!\NineColors{saturation=low}!}. |
| 163 |
|
| 164 |
\bigskip |
| 165 |
|
| 166 |
\textcolor{red4}{Ninecolors} package carefully selects and defines 9 colors for 13 hues each. |
| 167 |
All colors with the same suffix number have equal luminance level. |
| 168 |
Also color black is of level 0, and color white is of level 10. |
| 169 |
|
| 170 |
\bigskip |
| 171 |
|
| 172 |
\NineTestBack |
| 173 |
|
| 174 |
\medskip |
| 175 |
|
| 176 |
\NineTestFore |
| 177 |
|
| 178 |
\bigskip |
| 179 |
|
| 180 |
By simply choosing two colors in the above list, which differ in level by at least 5, |
| 181 |
as foreground and background colors, you will get proper |
| 182 |
\href{https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html}{WCAG Color Contrast}. |
| 183 |
|
| 184 |
\bigskip |
| 185 |
|
| 186 |
\NineTestContrast |
| 187 |
|
| 188 |
\bigskip |
| 189 |
|
| 190 |
If you need to select more contrasting foreground and background colors, which may have other hues, |
| 191 |
you could visit \href{https://lvjr.bitbucket.io/contrast.html}{WCAG Color Contrast Tool} |
| 192 |
page which is designed by the first author. |
| 193 |
|
| 194 |
\newpage |
| 195 |
|
| 196 |
\section{LaTeX2 Colors with High Saturation} |
| 197 |
|
| 198 |
You can change the saturation of colors by {\color{red3}\verb!\NineColors!} command. |
| 199 |
By default {\color{red3}\verb!saturation=medium!}. |
| 200 |
|
| 201 |
\bigskip |
| 202 |
|
| 203 |
\NineTestAllSaturations |
| 204 |
|
| 205 |
\bigskip |
| 206 |
|
| 207 |
\NineColors{saturation=high} |
| 208 |
Colors in the remaining part of the page have been changed by |
| 209 |
{\color{red3}\verb!\NineColors{saturation=high}!}. |
| 210 |
|
| 211 |
\bigskip |
| 212 |
|
| 213 |
\textcolor{red4}{Ninecolors} package carefully selects and defines 9 colors for 13 hues each. |
| 214 |
All colors with the same suffix number have equal luminance level. |
| 215 |
Also color black is of level 0, and color white is of level 10. |
| 216 |
|
| 217 |
\bigskip |
| 218 |
|
| 219 |
\NineTestBack |
| 220 |
|
| 221 |
\medskip |
| 222 |
|
| 223 |
\NineTestFore |
| 224 |
|
| 225 |
\bigskip |
| 226 |
|
| 227 |
By simply choosing two colors in the above list, which differ in level by at least 5, |
| 228 |
as foreground and background colors, you will get proper |
| 229 |
\href{https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html}{WCAG Color Contrast}. |
| 230 |
|
| 231 |
\bigskip |
| 232 |
|
| 233 |
\NineTestContrast |
| 234 |
|
| 235 |
\bigskip |
| 236 |
|
| 237 |
If you need to select more contrasting foreground and background colors, which may have other hues, |
| 238 |
you could visit \href{https://lvjr.bitbucket.io/contrast.html}{WCAG Color Contrast Tool} |
| 239 |
page which is designed by the first author. |
| 240 |
|
| 241 |
\newpage |
| 242 |
|
| 243 |
\section{LaTeX3 Colors for Fun} |
| 244 |
|
| 245 |
\NineColors{saturation=medium} |
| 246 |
|
| 247 |
If you are using a LaTeX3 release not older than 2021-07-12, |
| 248 |
\textcolor{red4}{Ninecolors} package will define LaTeX3 colors of the same names for you. |
| 249 |
|
| 250 |
\bigskip |
| 251 |
|
| 252 |
For example, you can change the color of drawing operations by |
| 253 |
{\color{red3}\verb!\color_fill:n {⟨color expression⟩}!} command |
| 254 |
for fills, |
| 255 |
{\color{red3}\verb!\color_stroke:n {⟨color expression⟩}!} command |
| 256 |
for strokes. |
| 257 |
%between {\color{red3}\verb!\ExplSyntaxOn!} and |
| 258 |
%{\color{red3}\verb!\ExplSyntaxOff!}. |
| 259 |
|
| 260 |
\bigskip |
| 261 |
|
| 262 |
\NineTestDraw |
| 263 |
|
| 264 |
\end{document} |