summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tuda-ci/tex/tudacolors.sty
blob: e67cab297379ec93fb62d652892b0487ce61b7fd (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
%% This is file `tudacolors.sty' version 2.09 (2020/03/09),
%% it is part of
%% TUDa-CI -- Corporate Design for TU Darmstadt
%% ----------------------------------------------------------------------------
%%
%%  Copyright (C) 2018--2020 by Marei Peischl <marei@peitex.de>
%%
%% ============================================================================
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2008/05/04 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainers of this work are
%%   Marei Peischl <tuda-ci@peitex.de>
%%   Markus Lazanowski <latex@ce.tu-darmstadt.de>
%%
%% The development respository can be found at
%% https://github.com/tudace/tuda_latex_templates
%% Please use the issue tracker for feedback!
%%
%% ============================================================================
%%
\def\fileversion{2.09}
\def\filedate{2020/03/09}
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
\ProvidesExplPackage{tudacolors}{\filedate}{\fileversion}{Color definition for TU Darmstadt's tuda-ci bundle}

\RequirePackage{l3keys2e}

\keys_define:nn {TUDa/colors} {
	accent .tl_gset:N = \g_TUDa_color_accent_tl,
	accent .initial:n = 0b,
	textaccent .tl_gset:N = \g_TUDa_color_textaccent_tl,
	textaccent .initial:n = \g_TUDa_color_accent_tl,
	identbar .tl_gset:N = \g_TUDa_color_identbar_tl,
	identbar .initial:n = \g_TUDa_color_accent_tl,
	accentcolor .meta:n = {accent =#1},
	textaccentcolor .meta:n = {textaccent = #1},
	identbarcolor .meta:n = {identbar = #1},
	color .meta:n = {accent=#1, textaccent=#1, identbar=#1},
	text .choice:,
	text/preferblack .code:n = \bool_gset_false:N \g_TUDa_color_whitetext_bool,
	text/preferwhite .code:n = \bool_gset_true:N  \g_TUDa_color_whitetext_bool,
	text .initial:n = {preferwhite},
	text/black .meta:n = {text=preferblack},
	text/white .meta:n = {text=preferwhite},
	cmyk .code:n = \PassOptionsToPackage{cmyk}{xcolor},
	RGB .code:n = \PassOptionsToPackage{RGB}{xcolor},
}

\ProcessKeysOptions{TUDa/colors}

\RequirePackage{xcolor}

\input{tudacolors.def}

\clist_map_inline:nn {accent, textaccent, identbar} {
	\cs_if_exist:cF {\string\color@\tl_use:c {g_TUDa_color_#1_tl}} {
		\cs_if_exist:cT {\string\color@TUDa-\tl_use:c {g_TUDa_color_#1_tl}} {
			\tl_gset:cx {g_TUDa_color_#1_tl} {TUDa-\tl_use:c {g_TUDa_color_#1_tl}}
	}}
}

\clist_const:Nn \c_TUDa_color_forbid_textaccent_clist {TUDa-0a,TUDa-5a,TUDa-6a,TUDa-6b,TUDa-7a}
\clist_const:Nn \c_TUDa_color_allow_blacktext_clist {TUDa-0a,TUDa-0b,TUDa-0c,TUDa-1a,TUDa-2a,TUDa-3a,TUDa-4a,TUDa-4b,TUDa-4c,TUDa-5a,TUDa-5b,TUDa-5c,TUDa-6a,TUDa-6b,TUDa-6c,TUDa-7a,TUDa-7b,TUDa-7c,TUDa-8a,TUDa-8b,TUDa-8c,TUDa-9a,TUDa-9b,TUDa-10a}
\clist_const:Nn \c_TUDa_color_allow_whitetext_clist {TUDa-0b,TUDa-0c,TUDa-0d,black,TUDa-1a,TUDa-1b,TUDa-1c,TUDa-1d,TUDa-2a,TUDa-2b,TUDa-2c,TUDa-2d,TUDa-3a,TUDa-3b,TUDa-3c,TUDa-3d,TUDa-4b,TUDa-4c,TUDa-4d,TUDa-5b,TUDa-5c,TUDa-5d,TUDa-6c,TUDa-6d,TUDa-7b,TUDa-7c,TUDa-7d,TUDa-8a,TUDa-8b,TUDa-8c,TUDa-8d,TUDa-9a,TUDa-9b,TUDa-9c,TUDa-9d,TUDa-10a,TUDa-10b,TUDa-10c,TUDa-10d,TUDa-11a,TUDa-11b,TUDa-11c,TUDa-11d}


%messages
\msg_new:nnnn {tudacolors} {undefined-color} {The~ color~ #1~ you~ selected~ is~ not~ defined.} {See~ the~ tuda-ci~ manual~ for~ a~ list~ of~ available~ colors.}
\msg_new:nnnn {tudacolors} {unselectable-color} {The~ color~ you~ selected~ (#1)~ must~ not~ be~ choosen~ for~ #2.} {See~ the~ Corporate~ Design~ Guidelines~ for~ further~ information.}

%select accentcolor
\exp_args:Nnx \colorlet{accentcolor}{\g_TUDa_color_accent_tl}
\bool_if:NTF \g_TUDa_color_whitetext_bool {
	\clist_if_in:NVTF \c_TUDa_color_allow_whitetext_clist \g_TUDa_color_accent_tl {
		\colorlet{textonaccentcolor}{white}
	} {
		\colorlet{textonaccentcolor}{black}
		\tl_if_in:NnT \g_TUDa_color_accent_tl {TUDa} {\msg_warning:nnxx {tudacolors} {unselectable-color} {white} {textonaccentcolor}}
	}
} {
	\clist_if_in:NVTF \c_TUDa_color_allow_blacktext_clist \g_TUDa_color_accent_tl {
		\colorlet{textonaccentcolor}{black}
	} {
		\colorlet{textonaccentcolor}{white}
		\tl_if_in:NnT \g_TUDa_color_accent_tl {TUDa} {msg_warning:nnxx {tudacolors} {unselectable-color} {black} {textonaccentcolor}}
	}
}

\colorlet{identbarcolor}{\g_TUDa_color_identbar_tl}


\exp_args:NNx \clist_if_in:NnTF \c_TUDa_color_forbid_textaccent_clist {\g_TUDa_color_textaccent_tl} {
	\msg_warning:nnxx {tudacolors} {unselectable-color} {\g_TUDa_color_textaccent_tl} {textaccentcolor}
	\colorlet{textaccentcolor}{black}
} {
 	\colorlet{textaccentcolor}{\g_TUDa_color_textaccent_tl}
}


\endinput