summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tuda-ci/tex/tudacolors.sty
blob: 0b8aa19028136367fa8a5404e06bb4fd03c3c47d (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
%% This is file `tudacolors.sty' version 3.20 (2021/10/12),
%% it is part of
%% TUDa-CI -- Corporate Design for TU Darmstadt
%% ----------------------------------------------------------------------------
%%
%%  Copyright (C) 2018--2021 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{3.20}
\def\filedate{2021/10/12}
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
\ProvidesExplPackage{tudacolors}{\filedate}{\fileversion}{Color definition for TU Darmstadt's tuda-ci bundle}

\RequirePackage{l3keys2e}

\str_if_exist:NF \g_ptxcd_department_str {
	\str_new:N \g_ptxcd_department_str
	\str_gset:Nn \g_ptxcd_department_str {default}
}

\keys_define:nn {ptxcd/colors} {
	accent .tl_gset:N = \g_ptxcd_color_accent_tl,
	accent .initial:n = 0b,
	textaccent .tl_gset:N = \g_ptxcd_color_textaccent_tl,
	textaccent .initial:n = \g_ptxcd_color_accent_tl,
	identbar .tl_gset:N = \g_ptxcd_color_identbar_tl,
	identbar .initial:n = \g_ptxcd_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_ptxcd_color_whitetext_bool,
	text/preferwhite .code:n = \bool_gset_true:N  \g_ptxcd_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},
	department .choice:,
	department / default .code:n = \str_gset:Nn \g_ptxcd_department_str {default},
	department / mecheng .code:n = \str_gset:Nn \g_ptxcd_department_str {mecheng}\keys_set:nn {ptxcd/colors}{accent=TUDa-2d,identbar=TUDa-6b},
	department / unknown .code:n = {
		\str_gset:Nx \g_ptxcd_department_str {\l_keys_value_tl}
	},
	department .initial:V = \g_ptxcd_department_str,
	mecheng .meta:n = {department=mecheng},
}

\ProcessKeysOptions{ptxcd/colors}

\RequirePackage{xcolor}

\input{tudacolors.def}

\str_if_eq:VnT \g_ptxcd_department_str {mecheng} {
	\colorlet{TUDa-Primary1}{TUDa-6b}
	\colorlet{TUDa-Primary2}{TUDa-2d}
	\colorlet{TUDa-Secondary1}{TUDa-9a}
	\colorlet{TUDa-Secondary2}{TUDa-8a}
	\colorlet{TUDa-Secondary3}{TUDa-6a}
	\colorlet{TUDa-Secondary4}{TUDa-3a}
	\colorlet{TUDa-Secondary5}{TUDa-4a}
	\colorlet{TUDa-Secondary6}{TUDa-5a}
	\colorlet{TUDa-Arrow}{TUDa-Primary2}
}

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

\clist_const:Nn \c_ptxcd_color_forbid_textaccent_clist {TUDa-0a,TUDa-5a,TUDa-6a,TUDa-6b,TUDa-7a}
\clist_const:Nn \c_ptxcd_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_ptxcd_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_ptxcd_color_accent_tl}
\bool_if:NTF \g_ptxcd_color_whitetext_bool {
	\clist_if_in:NVTF \c_ptxcd_color_allow_whitetext_clist \g_ptxcd_color_accent_tl {
		\colorlet{textonaccentcolor}{white}
	} {
		\colorlet{textonaccentcolor}{black}
		\tl_if_in:NnT \g_ptxcd_color_accent_tl {TUDa} {\msg_warning:nnxx{tudacolors} {unselectable-color} {white} {textonaccentcolor}}
	}
} {
	\clist_if_in:NVTF \c_ptxcd_color_allow_blacktext_clist \g_ptxcd_color_accent_tl {
		\colorlet{textonaccentcolor}{black}
	} {
		\colorlet{textonaccentcolor}{white}
		\tl_if_in:NnT \g_ptxcd_color_accent_tl {TUDa} {msg_warning:nnxx{tudacolors} {unselectable-color} {black} {textonaccentcolor}}
	}
}

\colorlet{identbarcolor}{\g_ptxcd_color_identbar_tl}


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

\colorlet{InfoBox}{white}

\endinput