Debian Codegraph @

xslt/common/color.xsl

raw
1 <?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
2 <!--
3 This program is free software; you can redistribute it and/or modify it under
4 the terms of the GNU Lesser General Public License as published by the Free
5 Software Foundation; either version 2 of the License, or (at your option) any
6 later version.
7
8 This program is distributed in the hope that it will be useful, but WITHOUT
9 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 details.
12
13 You should have received a copy of the GNU Lesser General Public License
14 along with this program; see the file COPYING.LGPL. If not, see <http://www.gnu.org/licenses/>.
15 -->
16
17 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
18 xmlns:math="http://exslt.org/math"
19 exclude-result-prefixes="math"
20 version="1.0">
21
22 <!--!!==========================================================================
23 Colors
24 Common named colors and color utilities for output styling.
25 @revision[version=3.28 date=2016-01-03 status=final]
26
27 This stylesheet provides a common interface to specify custom colors for
28 transformations to presentation-oreinted formats. This allows similar
29 output for different types of input documents.
30
31 This stylesheet also provides a number of templates for manipulating colors
32 and extracting information about colors.
33 -->
34
35
36 <!--**==========================================================================
37 color.hex2dec
38 Convert a hexidecimal number to decimal.
39 @revision[version=3.28 date=2016-01-03 status=final]
40
41 [xsl:params]
42 $hex: The hexidecimal number to convert to decimal.
43
44 This template converts a hexidecimal number to decimal. It's useful for getting
45 the numeric values of color components in a hexidecimal color code.
46 -->
47 <xsl:template name="color.hex2dec">
48 <xsl:param name="hex"/>
49 <xsl:variable name="char" select="substring($hex, string-length($hex))"/>
50 <xsl:variable name="dec">
51 <xsl:choose>
52 <xsl:when test="$char = 'a' or $char = 'A'">10</xsl:when>
53 <xsl:when test="$char = 'b' or $char = 'B'">11</xsl:when>
54 <xsl:when test="$char = 'c' or $char = 'C'">12</xsl:when>
55 <xsl:when test="$char = 'd' or $char = 'D'">13</xsl:when>
56 <xsl:when test="$char = 'e' or $char = 'E'">14</xsl:when>
57 <xsl:when test="$char = 'f' or $char = 'F'">15</xsl:when>
58 <xsl:otherwise><xsl:value-of select="$char"/></xsl:otherwise>
59 </xsl:choose>
60 </xsl:variable>
61 <xsl:choose>
62 <xsl:when test="string-length($hex) = 1">
63 <xsl:value-of select="number($dec)"/>
64 </xsl:when>
65 <xsl:otherwise>
66 <xsl:variable name="tens">
67 <xsl:call-template name="color.hex2dec">
68 <xsl:with-param name="hex" select="substring($hex, 1, string-length($hex) - 1)"/>
69 </xsl:call-template>
70 </xsl:variable>
71 <xsl:value-of select="$dec + 16 * $tens"/>
72 </xsl:otherwise>
73 </xsl:choose>
74 </xsl:template>
75
76
77 <!--**==========================================================================
78 color.r
79 Extract the red component of a color.
80 @revision[version=3.28 date=2016-01-03 status=final]
81
82 [xsl:params]
83 $color: A color specified in hexidecimal, `rgb()`, or `rgba()`.
84
85 This template extracts the red portion of a color, returning a number between
86 0 and 255. It accepts six-digit and three-digit hexidecimal color codes,
87 colors specified with `rgb()`, and colors specified with `rgba()`. It does
88 not accept HSL or named HTML colors.
89 -->
90 <xsl:template name="color.r">
91 <xsl:param name="color"/>
92 <xsl:choose>
93 <xsl:when test="starts-with($color, '#') and string-length($color) = 7">
94 <xsl:call-template name="color.hex2dec">
95 <xsl:with-param name="hex" select="substring($color, 2, 2)"/>
96 </xsl:call-template>
97 </xsl:when>
98 <xsl:when test="starts-with($color, '#') and string-length($color) = 4">
99 <xsl:call-template name="color.hex2dec">
100 <xsl:with-param name="hex" select="concat(substring($color, 2, 1), substring($color, 2, 1))"/>
101 </xsl:call-template>
102 </xsl:when>
103 <xsl:when test="starts-with($color, 'rgb(') or starts-with($color, 'rgba(')">
104 <xsl:value-of select="substring-before(substring-after($color, '('), ',')"/>
105 </xsl:when>
106 </xsl:choose>
107 </xsl:template>
108
109
110 <!--**==========================================================================
111 color.g
112 Extract the green component of a color.
113 @revision[version=3.28 date=2016-01-03 status=final]
114
115 [xsl:params]
116 $color: A color specified in hexidecimal, `rgb()`, or `rgba()`.
117
118 This template extracts the green portion of a color, returning a number between
119 0 and 255. It accepts six-digit and three-digit hexidecimal color codes,
120 colors specified with `rgb()`, and colors specified with `rgba()`. It does
121 not accept HSL or named HTML colors.
122 -->
123 <xsl:template name="color.g">
124 <xsl:param name="color"/>
125 <xsl:choose>
126 <xsl:when test="starts-with($color, '#') and string-length($color) = 7">
127 <xsl:call-template name="color.hex2dec">
128 <xsl:with-param name="hex" select="substring($color, 4, 2)"/>
129 </xsl:call-template>
130 </xsl:when>
131 <xsl:when test="starts-with($color, '#') and string-length($color) = 4">
132 <xsl:call-template name="color.hex2dec">
133 <xsl:with-param name="hex" select="concat(substring($color, 3, 1), substring($color, 3, 1))"/>
134 </xsl:call-template>
135 </xsl:when>
136 <xsl:when test="starts-with($color, 'rgb(') or starts-with($color, 'rgba(')">
137 <xsl:value-of select="substring-before(substring-after($color, ','), ',')"/>
138 </xsl:when>
139 </xsl:choose>
140 </xsl:template>
141
142
143 <!--**==========================================================================
144 color.b
145 Extract the blue component of a color.
146 @revision[version=3.28 date=2016-01-03 status=final]
147
148 [xsl:params]
149 $color: A color specified in hexidecimal, `rgb()`, or `rgba()`.
150
151 This template extracts the blue portion of a color, returning a number between
152 0 and 255. It accepts six-digit and three-digit hexidecimal color codes,
153 colors specified with `rgb()`, and colors specified with `rgba()`. It does
154 not accept HSL or named HTML colors.
155 -->
156 <xsl:template name="color.b">
157 <xsl:param name="color"/>
158 <xsl:choose>
159 <xsl:when test="starts-with($color, '#') and string-length($color) = 7">
160 <xsl:call-template name="color.hex2dec">
161 <xsl:with-param name="hex" select="substring($color, 6, 2)"/>
162 </xsl:call-template>
163 </xsl:when>
164 <xsl:when test="starts-with($color, '#') and string-length($color) = 4">
165 <xsl:call-template name="color.hex2dec">
166 <xsl:with-param name="hex" select="concat(substring($color, 4, 1), substring($color, 4, 1))"/>
167 </xsl:call-template>
168 </xsl:when>
169 <xsl:when test="starts-with($color, 'rgb(')">
170 <xsl:value-of select="substring-before(
171 substring-after(substring-after($color, ','), ','),
172 ')')"/>
173 </xsl:when>
174 <xsl:when test="starts-with($color, 'rgba(')">
175 <xsl:value-of select="substring-before(
176 substring-after(substring-after($color, ','), ','),
177 ',')"/>
178 </xsl:when>
179 </xsl:choose>
180 </xsl:template>
181
182
183 <!--**==========================================================================
184 color.a
185 Extract the alpha value of a color.
186 @revision[version=3.28 date=2016-01-03 status=final]
187
188 [xsl:params]
189 $color: A color specified in hexidecimal, `rgb()`, or `rgba()`.
190
191 This template extracts the alpha, or opacity level, of a color. It returns a
192 number between 0.0 and 1.0. It accepts six-digit and three-digit hexidecimal
193 color codes, colors specified with `rgb()`, and colors specified with
194 `rgba()`. It does not accept HSL or named HTML colors. For colors specified
195 with anything other than `rgba()`, it always returns 1.0.
196 -->
197 <xsl:template name="color.a">
198 <xsl:param name="color"/>
199 <xsl:choose>
200 <xsl:when test="starts-with($color, 'rgba(')">
201 <xsl:value-of select="number(substring-before(substring-after(
202 substring-after(substring-after($color, ','), ','), ','), ')'))"/>
203 </xsl:when>
204 <xsl:otherwise>
205 <xsl:text>1.0</xsl:text>
206 </xsl:otherwise>
207 </xsl:choose>
208 </xsl:template>
209
210
211 <!--**==========================================================================
212 color.rl
213 Get the relative luminance of a color.
214 @revision[version=3.28 date=2016-01-03 status=final]
215
216 [xsl:params]
217 $color: A color specified in hexidecimal, `rgb()`, or `rgba()`.
218
219 This template calculates the relative luminance of a color, returning a number
220 between 0.0 and 1.0. The relative luminance is used when calculating color
221 contrast. The relative luminance algorithm is defined by the WCAG:
222
223 $link[>>http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef]
224
225 This template accepts six-digit and three-digit hexidecimal color codes, colors
226 specified with `rgb()`, and colors specified with `rgba()`. It does not accept
227 HSL or named HTML colors.
228 -->
229 <xsl:template name="color.rl">
230 <xsl:param name="color"/>
231 <xsl:variable name="r">
232 <xsl:variable name="rsrgb_">
233 <xsl:call-template name="color.r">
234 <xsl:with-param name="color" select="$color"/>
235 </xsl:call-template>
236 </xsl:variable>
237 <xsl:variable name="rsrgb" select="$rsrgb_ div 255"/>
238 <xsl:choose>
239 <xsl:when test="$rsrgb &gt; 0.03928">
240 <xsl:value-of select="math:power(($rsrgb + 0.055) div 1.055, 2.4)"/>
241 </xsl:when>
242 <xsl:otherwise>
243 <xsl:value-of select="$rsrgb div 12.92"/>
244 </xsl:otherwise>
245 </xsl:choose>
246 </xsl:variable>
247 <xsl:variable name="g">
248 <xsl:variable name="gsrgb_">
249 <xsl:call-template name="color.g">
250 <xsl:with-param name="color" select="$color"/>
251 </xsl:call-template>
252 </xsl:variable>
253 <xsl:variable name="gsrgb" select="$gsrgb_ div 255"/>
254 <xsl:choose>
255 <xsl:when test="$gsrgb &gt; 0.03928">
256 <xsl:value-of select="math:power(($gsrgb + 0.055) div 1.055, 2.4)"/>
257 </xsl:when>
258 <xsl:otherwise>
259 <xsl:value-of select="$gsrgb div 12.92"/>
260 </xsl:otherwise>
261 </xsl:choose>
262 </xsl:variable>
263 <xsl:variable name="b">
264 <xsl:variable name="bsrgb_">
265 <xsl:call-template name="color.b">
266 <xsl:with-param name="color" select="$color"/>
267 </xsl:call-template>
268 </xsl:variable>
269 <xsl:variable name="bsrgb" select="$bsrgb_ div 255"/>
270 <xsl:choose>
271 <xsl:when test="$bsrgb &gt; 0.03928">
272 <xsl:value-of select="math:power(($bsrgb + 0.055) div 1.055, 2.4)"/>
273 </xsl:when>
274 <xsl:otherwise>
275 <xsl:value-of select="$bsrgb div 12.92"/>
276 </xsl:otherwise>
277 </xsl:choose>
278 </xsl:variable>
279 <xsl:value-of select="(0.2126 * $r) + (0.0722 * $b) + (0.7152 * $g)"/>
280 </xsl:template>
281
282
283 <!--**==========================================================================
284 color.contrast
285 Get the contrast between two colors.
286 @revision[version=3.28 date=2016-01-03 status=final]
287
288 [xsl:params]
289 $bg: A color specified in hexidecimal, `rgb()`, or `rgba()`.
290 $fg: A color specified in hexidecimal, `rgb()`, or `rgba()`.
291
292 This template calculates the contrast ratio between colors. The contrast ratio
293 is a number between 1 and 21. The algorithm is defined by the WCAG:
294
295 $link[>>http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef]
296
297 This template calls {color.rl} to get the relative luminance of $bg and $fg.
298 It accepts six-digit and three-digit hexidecimal color codes, colors specified
299 with `rgb()`, and colors specified with `rgba()`. It does not accept HSL or
300 named HTML colors. Note that it does not take the alpha value into account when
301 calculating the contrast ratio. Semi-transparent colors will have a lower
302 actual contrast ratio than what is reported by this template.
303
304 The WCAG recommends a contrast ratio of at least 4.5 for normal text, and a
305 ratio of at least 3.0 for large-scale text.
306 -->
307 <xsl:template name="color.contrast">
308 <xsl:param name="bg"/>
309 <xsl:param name="fg"/>
310 <xsl:variable name="bg.rl">
311 <xsl:call-template name="color.rl">
312 <xsl:with-param name="color" select="$bg"/>
313 </xsl:call-template>
314 </xsl:variable>
315 <xsl:variable name="fg.rl">
316 <xsl:call-template name="color.rl">
317 <xsl:with-param name="color" select="$fg"/>
318 </xsl:call-template>
319 </xsl:variable>
320 <xsl:choose>
321 <xsl:when test="$bg.rl > $fg.rl">
322 <xsl:value-of select="round(100 * (($bg.rl + 0.05) div ($fg.rl + 0.05))) div 100"/>
323 </xsl:when>
324 <xsl:otherwise>
325 <xsl:value-of select="round(100 * (($fg.rl + 0.05) div ($bg.rl + 0.05))) div 100"/>
326 </xsl:otherwise>
327 </xsl:choose>
328 </xsl:template>
329
330
331 <!--**==========================================================================
332 color.blend
333 Blend two colors together at a specified mix level.
334 @revision[version=3.28 date=2016-01-03 status=final]
335
336 [xsl:params]
337 $bg: A color specified in hexidecimal, `rgb()`, or `rgba()`.
338 $fg: A color specified in hexidecimal, `rgb()`, or `rgba()`.
339 $mix: The mix level, between 0.0 and 1.0.
340
341 This template calculates a color by selecting a midpoint between $bg and
342 $fg, where the $mix parameter specifies how far to move from $bg to $fg
343 For opaque colors, setting $mix to 0.0 will result in $bg, and setting
344 $mix to 1.0 will result in $fg.
345
346 This template takes the alpha values of $bg and $fg into account, so
347 that specifying 1.0 for $mix will result in a color that is the result
348 of overlaying $fg on top of $bg. In effect, $mix acts as a multiplier
349 on the alpha channels of the colors.
350
351 This template calls {color.r}, {color.g}, {color.b}, and {color.a} to get
352 the components of $bg and $fg. It accepts six-digit and three-digit
353 hexidecimal color codes, colors specified with `rgb()`, and colors specified
354 with `rgba()`. It does not accept HSL or named HTML colors.
355
356 If the return color is fully opaque, this template returns the color using
357 the `rgb()` scheme. Otherwise, it uses the `rgba()` scheme.
358 -->
359 <xsl:template name="color.blend">
360 <xsl:param name="bg" select="'#ffffff'"/>
361 <xsl:param name="fg" select="'#000000'"/>
362 <xsl:param name="mix" select="0.5"/>
363
364 <xsl:variable name="fgr">
365 <xsl:call-template name="color.r">
366 <xsl:with-param name="color" select="$fg"/>
367 </xsl:call-template>
368 </xsl:variable>
369 <xsl:variable name="fgb">
370 <xsl:call-template name="color.b">
371 <xsl:with-param name="color" select="$fg"/>
372 </xsl:call-template>
373 </xsl:variable>
374 <xsl:variable name="fgg">
375 <xsl:call-template name="color.g">
376 <xsl:with-param name="color" select="$fg"/>
377 </xsl:call-template>
378 </xsl:variable>
379 <xsl:variable name="fga">
380 <xsl:call-template name="color.a">
381 <xsl:with-param name="color" select="$fg"/>
382 </xsl:call-template>
383 </xsl:variable>
384 <xsl:variable name="bgr">
385 <xsl:call-template name="color.r">
386 <xsl:with-param name="color" select="$bg"/>
387 </xsl:call-template>
388 </xsl:variable>
389 <xsl:variable name="bgb">
390 <xsl:call-template name="color.b">
391 <xsl:with-param name="color" select="$bg"/>
392 </xsl:call-template>
393 </xsl:variable>
394 <xsl:variable name="bgg">
395 <xsl:call-template name="color.g">
396 <xsl:with-param name="color" select="$bg"/>
397 </xsl:call-template>
398 </xsl:variable>
399 <xsl:variable name="bga">
400 <xsl:call-template name="color.a">
401 <xsl:with-param name="color" select="$bg"/>
402 </xsl:call-template>
403 </xsl:variable>
404
405 <xsl:variable name="a" select="($fga * $mix) + ($bga * (1 - $mix))"/>
406 <xsl:variable name="r" select="(($bgr * $bga * (1 - $mix)) +
407 ($fgr * $fga * $mix)) div $a"/>
408 <xsl:variable name="g" select="(($bgg * $bga * (1 - $mix)) +
409 ($fgg * $fga * $mix)) div $a"/>
410 <xsl:variable name="b" select="(($bgb * $bga * (1 - $mix)) +
411 ($fgb * $fga * $mix)) div $a"/>
412 <xsl:variable name="rgba" select="$a &lt; 1"/>
413 <xsl:choose>
414 <xsl:when test="$rgba">
415 <xsl:text>rgba(</xsl:text>
416 </xsl:when>
417 <xsl:otherwise>
418 <xsl:text>rgb(</xsl:text>
419 </xsl:otherwise>
420 </xsl:choose>
421 <xsl:choose>
422 <xsl:when test="$r &lt; 0">
423 <xsl:text>0</xsl:text>
424 </xsl:when>
425 <xsl:when test="$r &gt; 255">
426 <xsl:text>255</xsl:text>
427 </xsl:when>
428 <xsl:otherwise>
429 <xsl:value-of select="round($r)"/>
430 </xsl:otherwise>
431 </xsl:choose>
432 <xsl:text>,</xsl:text>
433 <xsl:choose>
434 <xsl:when test="$g &lt; 0">
435 <xsl:text>0</xsl:text>
436 </xsl:when>
437 <xsl:when test="$g &gt; 255">
438 <xsl:text>255</xsl:text>
439 </xsl:when>
440 <xsl:otherwise>
441 <xsl:value-of select="round($g)"/>
442 </xsl:otherwise>
443 </xsl:choose>
444 <xsl:text>,</xsl:text>
445 <xsl:choose>
446 <xsl:when test="$b &lt; 0">
447 <xsl:text>0</xsl:text>
448 </xsl:when>
449 <xsl:when test="$b &gt; 255">
450 <xsl:text>255</xsl:text>
451 </xsl:when>
452 <xsl:otherwise>
453 <xsl:value-of select="round($b)"/>
454 </xsl:otherwise>
455 </xsl:choose>
456 <xsl:if test="$rgba">
457 <xsl:text>,</xsl:text>
458 <xsl:choose>
459 <xsl:when test="$a &lt; 0">
460 <xsl:text>0</xsl:text>
461 </xsl:when>
462 <xsl:when test="$a &gt; 1.0">
463 <xsl:text>1.0</xsl:text>
464 </xsl:when>
465 <xsl:otherwise>
466 <xsl:value-of select="$a"/>
467 </xsl:otherwise>
468 </xsl:choose>
469 </xsl:if>
470 <xsl:text>)</xsl:text>
471 </xsl:template>
472
473
474 <!--#* _color.fgify -->
475 <xsl:template name="_color.fgify">
476 <xsl:param name="color"/>
477 <xsl:param name="target" select="5"/>
478 <xsl:param name="recdepth" select="0"/>
479 <xsl:param name="name"/>
480 <xsl:variable name="newcolor">
481 <xsl:call-template name="color.blend">
482 <xsl:with-param name="bg" select="$color"/>
483 <xsl:with-param name="fg" select="$color.fg"/>
484 <xsl:with-param name="mix" select="0.1"/>
485 </xsl:call-template>
486 </xsl:variable>
487 <xsl:variable name="contrast">
488 <xsl:call-template name="color.contrast">
489 <xsl:with-param name="bg" select="$color.bg"/>
490 <xsl:with-param name="fg" select="$newcolor"/>
491 </xsl:call-template>
492 </xsl:variable>
493 <xsl:choose>
494 <xsl:when test="$contrast >= $target">
495 <xsl:value-of select="$newcolor"/>
496 </xsl:when>
497 <xsl:when test="$recdepth > 10">
498 <xsl:message>
499 <xsl:text>Recursion depth exceeded calculating </xsl:text>
500 <xsl:if test="$name">
501 <xsl:value-of select="concat($name, ' ')"/>
502 </xsl:if>
503 <xsl:text>fg color. Using </xsl:text>
504 <xsl:value-of select="$newcolor"/>
505 </xsl:message>
506 <xsl:value-of select="$newcolor"/>
507 </xsl:when>
508 <xsl:otherwise>
509 <xsl:call-template name="_color.fgify">
510 <xsl:with-param name="color" select="$newcolor"/>
511 <xsl:with-param name="target" select="$target"/>
512 <xsl:with-param name="recdepth" select="$recdepth + 1"/>
513 <xsl:with-param name="name" select="$name"/>
514 </xsl:call-template>
515 </xsl:otherwise>
516 </xsl:choose>
517 </xsl:template>
518
519
520 <!--#@ color.background -->
521 <xsl:variable name="_color.isinverse">
522 <xsl:variable name="contrast">
523 <xsl:call-template name="color.contrast">
524 <xsl:with-param name="bg" select="'#000000'"/>
525 <xsl:with-param name="fg" select="$color.fg"/>
526 </xsl:call-template>
527 </xsl:variable>
528 <xsl:choose>
529 <xsl:when test="$contrast > 5">
530 <xsl:text>1</xsl:text>
531 </xsl:when>
532 <xsl:otherwise>
533 <xsl:text>0</xsl:text>
534 </xsl:otherwise>
535 </xsl:choose>
536 </xsl:variable>
537
538
539 <!--#* _color.bgify -->
540 <xsl:template name="_color.bgify">
541 <xsl:param name="color"/>
542 <xsl:param name="target">
543 <xsl:choose>
544 <xsl:when test="normalize-space($_color.isinverse) = '1'">
545 <xsl:value-of select="11"/>
546 </xsl:when>
547 <xsl:otherwise>
548 <xsl:value-of select="19"/>
549 </xsl:otherwise>
550 </xsl:choose>
551 </xsl:param>
552 <xsl:param name="recdepth" select="0"/>
553 <xsl:param name="name"/>
554 <xsl:variable name="newcolor">
555 <xsl:call-template name="color.blend">
556 <xsl:with-param name="bg" select="$color"/>
557 <xsl:with-param name="fg" select="$color.bg"/>
558 <xsl:with-param name="mix" select="0.2"/>
559 </xsl:call-template>
560 </xsl:variable>
561 <xsl:variable name="contrast">
562 <xsl:call-template name="color.contrast">
563 <xsl:with-param name="bg" select="$newcolor"/>
564 <xsl:with-param name="fg" select="$color.fg"/>
565 </xsl:call-template>
566 </xsl:variable>
567 <xsl:choose>
568 <xsl:when test="$contrast >= $target">
569 <xsl:value-of select="$newcolor"/>
570 </xsl:when>
571 <xsl:when test="$recdepth > 20">
572 <xsl:message>
573 <xsl:text>Recursion depth exceeded calculating </xsl:text>
574 <xsl:if test="$name">
575 <xsl:value-of select="concat($name, ' ')"/>
576 </xsl:if>
577 <xsl:text>bg color. Using </xsl:text>
578 <xsl:value-of select="$newcolor"/>
579 </xsl:message>
580 <xsl:value-of select="$newcolor"/>
581 </xsl:when>
582 <xsl:otherwise>
583 <xsl:call-template name="_color.bgify">
584 <xsl:with-param name="color" select="$newcolor"/>
585 <xsl:with-param name="target" select="$target"/>
586 <xsl:with-param name="recdepth" select="$recdepth + 1"/>
587 <xsl:with-param name="name" select="$name"/>
588 </xsl:call-template>
589 </xsl:otherwise>
590 </xsl:choose>
591 </xsl:template>
592
593
594
595 <!--@@==========================================================================
596 color.fg
597 The primary text color.
598 @revision[version=3.28 date=2016-01-03 status=final]
599
600 This parameters specifies the normal color of text. It should have a high color
601 contrast against {color.bg}. Other text colors can be automatically computed
602 based on this color.
603 -->
604 <xsl:param name="color.fg" select="'#000000'"/>
605
606
607 <!--@@==========================================================================
608 color.bg
609 The normal background color.
610 @revision[version=3.28 date=2016-01-03 status=final]
611
612 This parameters specifies the background color. It should have a high color
613 contrast against {color.fg}. Other background colors can be automatically
614 computed based on this color.
615 -->
616 <xsl:param name="color.bg" select="'#ffffff'"/>
617
618
619 <!--@@==========================================================================
620 color.red
621 A red accent color.
622 @revision[version=3.28 date=2016-01-03 status=final]
623
624 This parameter specifies a shade of red that is suitable for borders and
625 other accents. It should have some contrast against background colors, but it
626 does not need as high of a contrast as text colors.
627 -->
628 <xsl:param name="color.red" select="'#c01c28'"/>
629
630
631 <!--@@==========================================================================
632 color.fg.red
633 A red text color.
634 @revision[version=3.28 date=2016-01-03 status=final]
635
636 This parameter specifies a shade of red that is suitable for text. It should
637 have a high color contrast against {color.bg}. If not specified, it can be
638 automatically computed based on {color.red} and {color.fg}.
639 -->
640 <xsl:param name="color.fg.red">
641 <xsl:call-template name="_color.fgify">
642 <xsl:with-param name="color" select="$color.red"/>
643 <xsl:with-param name="name" select="'red'"/>
644 </xsl:call-template>
645 </xsl:param>
646
647
648 <!--@@==========================================================================
649 color.bg.red
650 A red background color.
651 @revision[version=3.28 date=2016-01-03 status=final]
652
653 This parameter specifies a shade of red that is suitable for backgrounds.
654 It should have a high color contrast against {color.fg}. If not specified,
655 it can be automatically computed based on {color.red} and {color.bg}.
656 -->
657 <xsl:param name="color.bg.red">
658 <xsl:call-template name="_color.bgify">
659 <xsl:with-param name="color" select="$color.red"/>
660 <xsl:with-param name="name" select="'red'"/>
661 </xsl:call-template>
662 </xsl:param>
663
664
665 <!--@@==========================================================================
666 color.orange
667 An orange accent color.
668 @revision[version=3.28 date=2016-01-03 status=final]
669
670 This parameter specifies a shade of orange that is suitable for borders and
671 other accents. It should have some contrast against background colors, but it
672 does not need as high of a contrast as text colors.
673 -->
674 <xsl:param name="color.orange" select="'#ffa348'"/>
675
676
677 <!--@@==========================================================================
678 color.fg.orange
679 An orange text color.
680 @revision[version=3.28 date=2016-01-03 status=final]
681
682 This parameter specifies a shade of orange that is suitable for text. It should
683 have a high color contrast against {color.bg}. If not specified, it can be
684 automatically computed based on {color.orange} and {color.fg}.
685 -->
686 <xsl:param name="color.fg.orange">
687 <xsl:call-template name="_color.fgify">
688 <xsl:with-param name="color" select="$color.orange"/>
689 <xsl:with-param name="name" select="'orange'"/>
690 </xsl:call-template>
691 </xsl:param>
692
693
694 <!--@@==========================================================================
695 color.bg.orange
696 An orange background color.
697 @revision[version=3.28 date=2016-01-03 status=final]
698
699 This parameter specifies a shade of orange that is suitable for backgrounds.
700 It should have a high color contrast against {color.fg}. If not specified,
701 it can be automatically computed based on {color.orange} and {color.bg}.
702 -->
703 <xsl:param name="color.bg.orange">
704 <xsl:call-template name="_color.bgify">
705 <xsl:with-param name="color" select="$color.orange"/>
706 <xsl:with-param name="name" select="'orange'"/>
707 </xsl:call-template>
708 </xsl:param>
709
710
711 <!--@@==========================================================================
712 color.yellow
713 A yellow accent color.
714 @revision[version=3.28 date=2016-01-03 status=final]
715
716 This parameter specifies a shade of yellow that is suitable for borders and
717 other accents. It should have some contrast against background colors, but it
718 does not need as high of a contrast as text colors.
719 -->
720 <xsl:param name="color.yellow" select="'#f8e45c'"/>
721
722
723 <!--@@==========================================================================
724 color.fg.yellow
725 A yellow text color.
726 @revision[version=3.28 date=2016-01-03 status=final]
727
728 This parameter specifies a shade of yellow that is suitable for text. It should
729 have a high color contrast against {color.bg}. If not specified, it can be
730 automatically computed based on {color.yellow} and {color.fg}.
731 -->
732 <xsl:param name="color.fg.yellow">
733 <xsl:call-template name="_color.fgify">
734 <xsl:with-param name="color" select="$color.yellow"/>
735 <xsl:with-param name="target" select="5.5"/>
736 <xsl:with-param name="name" select="'yellow'"/>
737 </xsl:call-template>
738 </xsl:param>
739
740
741 <!--@@==========================================================================
742 color.bg.yellow
743 A yellow background color.
744 @revision[version=3.28 date=2016-01-03 status=final]
745
746 This parameter specifies a shade of yellow that is suitable for backgrounds.
747 It should have a high color contrast against {color.fg}. If not specified,
748 it can be automatically computed based on {color.yellow} and {color.bg}.
749 -->
750 <xsl:param name="color.bg.yellow">
751 <xsl:call-template name="_color.bgify">
752 <xsl:with-param name="color" select="$color.yellow"/>
753 <xsl:with-param name="target">
754 <xsl:choose>
755 <xsl:when test="normalize-space($_color.isinverse) = '1'">
756 <xsl:value-of select="9"/>
757 </xsl:when>
758 <xsl:otherwise>
759 <xsl:value-of select="20"/>
760 </xsl:otherwise>
761 </xsl:choose>
762 </xsl:with-param>
763 <xsl:with-param name="name" select="'yellow'"/>
764 </xsl:call-template>
765 </xsl:param>
766
767
768 <!--@@==========================================================================
769 color.green
770 A green accent color.
771 @revision[version=3.28 date=2016-01-03 status=final]
772
773 This parameter specifies a shade of green that is suitable for borders and
774 other accents. It should have some contrast against background colors, but it
775 does not need as high of a contrast as text colors.
776 -->
777 <xsl:param name="color.green" select="'#57e389'"/>
778
779
780 <!--@@==========================================================================
781 color.fg.green
782 A green text color.
783 @revision[version=3.28 date=2016-01-03 status=final]
784
785 This parameter specifies a shade of green that is suitable for text. It should
786 have a high color contrast against {color.bg}. If not specified, it can be
787 automatically computed based on {color.green} and {color.fg}.
788 -->
789 <xsl:param name="color.fg.green">
790 <xsl:call-template name="_color.fgify">
791 <xsl:with-param name="color" select="$color.green"/>
792 <xsl:with-param name="name" select="'green'"/>
793 </xsl:call-template>
794 </xsl:param>
795
796
797 <!--@@==========================================================================
798 color.bg.green
799 A green background color.
800 @revision[version=3.28 date=2016-01-03 status=final]
801
802 This parameter specifies a shade of green that is suitable for backgrounds.
803 It should have a high color contrast against {color.fg}. If not specified,
804 it can be automatically computed based on {color.green} and {color.bg}.
805 -->
806 <xsl:param name="color.bg.green">
807 <xsl:call-template name="_color.bgify">
808 <xsl:with-param name="color" select="$color.green"/>
809 <xsl:with-param name="name" select="'green'"/>
810 </xsl:call-template>
811 </xsl:param>
812
813
814 <!--@@==========================================================================
815 color.blue
816 A blue accent color.
817 @revision[version=3.28 date=2016-01-03 status=final]
818
819 This parameter specifies a shade of blue that is suitable for borders and
820 other accents. It should have some contrast against background colors, but it
821 does not need as high of a contrast as text colors.
822 -->
823 <xsl:param name="color.blue" select="'#3584e4'"/>
824
825
826 <!--@@==========================================================================
827 color.fg.blue
828 A blue text color.
829 @revision[version=3.28 date=2016-01-03 status=final]
830
831 This parameter specifies a shade of blue that is suitable for text. It should
832 have a high color contrast against {color.bg}. If not specified, it can be
833 automatically computed based on {color.blue} and {color.fg}.
834 -->
835 <xsl:param name="color.fg.blue">
836 <xsl:call-template name="_color.fgify">
837 <xsl:with-param name="color" select="$color.blue"/>
838 <xsl:with-param name="name" select="'blue'"/>
839 </xsl:call-template>
840 </xsl:param>
841
842 <!--@@==========================================================================
843 color.bg.blue
844 A blue background color.
845 @revision[version=3.28 date=2016-01-03 status=final]
846
847 This parameter specifies a shade of blue that is suitable for backgrounds.
848 It should have a high color contrast against {color.fg}. If not specified,
849 it can be automatically computed based on {color.blue} and {color.bg}.
850 -->
851 <xsl:param name="color.bg.blue">
852 <xsl:call-template name="_color.bgify">
853 <xsl:with-param name="color" select="$color.blue"/>
854 <xsl:with-param name="name" select="'blue'"/>
855 </xsl:call-template>
856 </xsl:param>
857
858
859 <!--@@==========================================================================
860 color.purple
861 A purple accent color.
862 @revision[version=3.28 date=2016-01-03 status=final]
863
864 This parameter specifies a shade of purple that is suitable for borders and
865 other accents. It should have some contrast against background colors, but it
866 does not need as high of a contrast as text colors.
867 -->
868 <xsl:param name="color.purple" select="'#a347ba'"/>
869
870
871 <!--@@==========================================================================
872 color.fg.purple
873 A purple text color.
874 @revision[version=3.28 date=2016-01-03 status=final]
875
876 This parameter specifies a shade of purple that is suitable for text. It should
877 have a high color contrast against {color.bg}. If not specified, it can be
878 automatically computed based on {color.purple} and {color.fg}.
879 -->
880 <xsl:param name="color.fg.purple">
881 <xsl:call-template name="_color.fgify">
882 <xsl:with-param name="color" select="$color.purple"/>
883 <xsl:with-param name="name" select="'purple'"/>
884 </xsl:call-template>
885 </xsl:param>
886
887
888 <!--@@==========================================================================
889 color.bg.purple
890 A purple background color.
891 @revision[version=3.28 date=2016-01-03 status=final]
892
893 This parameter specifies a shade of purple that is suitable for backgrounds.
894 It should have a high color contrast against {color.fg}. If not specified,
895 it can be automatically computed based on {color.purple} and {color.bg}.
896 -->
897 <xsl:param name="color.bg.purple">
898 <xsl:call-template name="_color.bgify">
899 <xsl:with-param name="color" select="$color.purple"/>
900 <xsl:with-param name="name" select="'purple'"/>
901 </xsl:call-template>
902 </xsl:param>
903
904
905 <!--@@==========================================================================
906 color.gray
907 A gray accent color.
908 @revision[version=3.28 date=2016-01-03 status=final]
909
910 This parameter specifies a shade of gray that is suitable for borders and
911 other accents. It should have some contrast against background colors, but it
912 does not need as high of a contrast as text colors.
913 -->
914 <xsl:param name="color.gray" select="'#c0bfbc'"/>
915
916
917 <!--@@==========================================================================
918 color.fg.gray
919 A gray text color.
920 @revision[version=3.28 date=2016-01-03 status=final]
921
922 This parameter specifies a shade of gray that is suitable for text. It should
923 have a high color contrast against {color.bg}. If not specified, it can be
924 automatically computed based on {color.gray} and {color.fg}.
925 -->
926 <xsl:param name="color.fg.gray">
927 <xsl:call-template name="_color.fgify">
928 <xsl:with-param name="color" select="$color.gray"/>
929 <xsl:with-param name="name" select="'gray'"/>
930 </xsl:call-template>
931 </xsl:param>
932
933
934 <!--@@==========================================================================
935 color.bg.gray
936 A gray background color.
937 @revision[version=3.28 date=2016-01-03 status=final]
938
939 This parameter specifies a shade of gray that is suitable for backgrounds.
940 It should have a high color contrast against {color.fg}. If not specified,
941 it can be automatically computed based on {color.gray} and {color.bg}.
942 -->
943 <xsl:param name="color.bg.gray">
944 <xsl:call-template name="_color.bgify">
945 <xsl:with-param name="color" select="$color.gray"/>
946 <xsl:with-param name="name" select="'gray'"/>
947 </xsl:call-template>
948 </xsl:param>
949
950
951 <!--@@==========================================================================
952 color.fg.dark
953 A dark gray text color.
954 @revision[version=3.28 date=2016-01-03 status=final]
955
956 This parameter specifies a dark shade of gray that is suitable for text. It
957 should have a very high color contrast against {color.bg}. It is typically
958 used to slightly reduce the visual weight of headers and bold text. If not
959 specified, it can be automatically computed based on {color.gray} and
960 {color.fg}.
961 -->
962 <xsl:param name="color.fg.dark">
963 <xsl:call-template name="_color.fgify">
964 <xsl:with-param name="color" select="$color.gray"/>
965 <xsl:with-param name="target" select="8"/>
966 <xsl:with-param name="name" select="'dark'"/>
967 </xsl:call-template>
968 </xsl:param>
969
970
971 <!--@@==========================================================================
972 color.bg.dark
973 A dark gray background color.
974 @revision[version=3.28 date=2016-01-03 status=final]
975
976 This parameter specifies a shade of gray that is suitable for backgrounds,
977 and is darker than {color.bg.gray}. It should have a high color contrast
978 against {color.fg}. It is typically used at the intersection of shaded
979 rows and columns in a table, or as a very light gray accent color. If not
980 specified, it can be automatically computed based on {color.gray} and
981 {color.bg}.
982 -->
983 <xsl:param name="color.bg.dark">
984 <xsl:call-template name="_color.bgify">
985 <xsl:with-param name="color" select="$color.gray"/>
986 <xsl:with-param name="target">
987 <xsl:choose>
988 <xsl:when test="normalize-space($_color.isinverse) = '1'">
989 <xsl:value-of select="9"/>
990 </xsl:when>
991 <xsl:otherwise>
992 <xsl:value-of select="17"/>
993 </xsl:otherwise>
994 </xsl:choose>
995 </xsl:with-param>
996 <xsl:with-param name="name" select="'dark'"/>
997 </xsl:call-template>
998 </xsl:param>
999
1000
1001 <!--
1002 Old color parameters below. Kept for compatibility with existing
1003 customizations that reference these colors.
1004 -->
1005
1006 <!--#@ color.background -->
1007 <xsl:param name="color.background" select="$color.bg"/>
1008
1009 <!--#@ color.link -->
1010 <xsl:param name="color.link" select="$color.fg.blue"/>
1011
1012 <!--#@ color.link_visited -->
1013 <xsl:param name="color.link_visited" select="$color.fg.purple"/>
1014
1015 <!--#@ color.text -->
1016 <xsl:param name="color.text" select="$color.fg"/>
1017
1018 <!--#@ color.text_light -->
1019 <xsl:param name="color.text_light" select="$color.fg.dark"/>
1020
1021 <!--#@ color.text_error -->
1022 <xsl:param name="color.text_error" select="$color.fg.red"/>
1023
1024 <!--#@ color.blue_background -->
1025 <xsl:param name="color.blue_background" select="$color.bg.blue"/>
1026
1027 <!--#@ color.blue_border -->
1028 <xsl:param name="color.blue_border" select="$color.blue"/>
1029
1030 <!--#@ color.gray_background -->
1031 <xsl:param name="color.gray_background" select="$color.bg.gray"/>
1032
1033 <!--#@ color.dark_background -->
1034 <xsl:param name="color.dark_background" select="$color.bg.dark"/>
1035
1036 <!--#@ color.gray_border -->
1037 <xsl:param name="color.gray_border" select="$color.gray"/>
1038
1039 <!--#@ color.red_background -->
1040 <xsl:param name="color.red_background" select="$color.bg.red"/>
1041
1042 <!--#@ color.red_border -->
1043 <xsl:param name="color.red_border" select="$color.red"/>
1044
1045 <!--#@ color.yellow_background -->
1046 <xsl:param name="color.yellow_background" select="$color.bg.yellow"/>
1047
1048 <!--#@ color.yellow_border -->
1049 <xsl:param name="color.yellow_border" select="$color.yellow"/>
1050
1051
1052 </xsl:stylesheet>