summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/ninecolors/ninecolors.tex
blob: 812ea72a9be350fd7ed822066efbf60bc7370546 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
%  -*- coding: utf-8 -*-
\documentclass{article}
\usepackage[a4paper,margin=1.5cm]{geometry}

\usepackage{ninecolors}
\usepackage{arev}
\usepackage{pgffor}
\usepackage{hyperref}
\hypersetup{
  colorlinks=true,
  urlcolor=blue3,
}

\newcommand*{\myversion}{2021B}
\newcommand*{\mydate}{Version \myversion\ (\the\year-\mylpad\month-\mylpad\day)}
\newcommand*{\mylpad}[1]{\ifnum#1<10 0\the#1\else\the#1\fi}

\begin{document}

\title{\textcolor{blue3}{Ninecolors: select colors with proper WCAG color contrast}%
       \footnote{\url{https://github.com/lvjr/ninecolors}}}
\author{Jianrui Lyu (tolvjr@163.com)}
\date{\mydate}
\maketitle

\textcolor{red4}{Ninecolors} package carefully selects and defines 9 colors for 13 hues each.
All colors with the same suffix number have equal luminance level.
Also color black is of level 0, and color white is of level 10.

\bigskip

\newcommand{\NineTestBack}{%
\foreach \l in {1,...,9}
{
  \noindent
  \foreach \n in {gray,red,brown,yellow,olive,green,teal,cyan,azure,blue,violet,magenta,purple}
  {%
    \xdef\mycolor{\ifnum \l < 5 white\else black\fi}%
    \colorbox{\n\l}{\color{\mycolor}\texttt\strut\n\l}%
  }
  \par
}}
\NineTestBack

\bigskip

\newcommand{\NineTestFore}{%
\foreach \l in {1,...,9}
{
  \noindent
  \foreach \n in {gray,red,brown,yellow,olive,green,teal,cyan,azure,blue,violet,magenta,purple}
  {%
    \xdef\mycolor{\ifnum \l < 5 gray9\else black\fi}%
    \colorbox{\mycolor}{\color{\n\l}\texttt\strut\n\l}%
  }
  \par
}}
\NineTestFore

\bigskip
\hrule
\bigskip

By simply choosing two colors in the above list, which differ in level by at least 5,
as foreground and background colors, you will get proper
\href{https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html}{WCAG Color Contrast}.

\bigskip

\newcommand{\NineTestContrast}{%
\colorbox{blue9}{%
  \strut\color{green3}The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
}
\par\nointerlineskip
\colorbox{green3}{%
  \strut\color{blue9}The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
}
\par\nointerlineskip
\colorbox{violet9}{%
  \strut\color{brown3}The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
}
\par\nointerlineskip
\colorbox{brown3}{%
  \strut\color{violet9}The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
}}
\NineTestContrast

\bigskip
\hrule
\bigskip

If you need to select more contrasting foreground and background colors, which may have other hues,
you could visit \href{https://lvjr.bitbucket.io/contrast.html}{WCAG Color Contrast Tool}
page which is designed by the author.

\newpage\vspace*{31mm}
\NineColors{saturation=low}

You can change the saturation of colors by {\color{red3}\verb!\NineColors!} command.
By default {\color{red3}\verb!saturation=medium!}.
Colors in this page have been changed by {\color{red3}\verb!\NineColors{saturation=low}!}.

\bigskip

\textcolor{red4}{Ninecolors} package carefully selects and defines 9 colors for 13 hues each.
All colors with the same suffix number have equal luminance level.
Also color black is of level 0, and color white is of level 10.

\bigskip

\NineTestBack

\bigskip

\NineTestFore

\bigskip
\hrule
\bigskip

By simply choosing two colors in the above list, which differ in level by at least 5,
as foreground and background colors, you will get proper
\href{https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html}{WCAG Color Contrast}.

\bigskip

\NineTestContrast

\bigskip
\hrule
\bigskip

If you need to select more contrasting foreground and background colors, which may have other hues,
you could visit \href{https://lvjr.bitbucket.io/contrast.html}{WCAG Color Contrast Tool}
page which is designed by the author.

\newpage\vspace*{31mm}
\NineColors{saturation=high}

You can change the saturation of colors by {\color{red3}\verb!\NineColors!} command.
By default {\color{red3}\verb!saturation=medium!}.
Colors in this page have been changed by {\color{red3}\verb!\NineColors{saturation=high}!}.

\bigskip

\textcolor{red4}{Ninecolors} package carefully selects and defines 9 colors for 13 hues each.
All colors with the same suffix number have equal luminance level.
Also color black is of level 0, and color white is of level 10.

\bigskip

\NineTestBack

\bigskip

\NineTestFore

\bigskip
\hrule
\bigskip

By simply choosing two colors in the above list, which differ in level by at least 5,
as foreground and background colors, you will get proper
\href{https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html}{WCAG Color Contrast}.

\bigskip

\NineTestContrast

\bigskip
\hrule
\bigskip

If you need to select more contrasting foreground and background colors, which may have other hues,
you could visit \href{https://lvjr.bitbucket.io/contrast.html}{WCAG Color Contrast Tool}
page which is designed by the author.

\end{document}