e90f87286ae93252f775273998802a079b4ee7f4
[platform/upstream/groff.git] / contrib / hdtbl / examples / rainbow.roff
1 .\" -*- mode: nroff -*-
2 .ig
3
4 rainbow.roff
5
6 This file is part of groff, the GNU roff type-setting system.
7
8 Copyright (C) 2005-2014  Free Software Foundation, Inc.
9 written by Joachim Walsdorff <Joachim.Walsdorff@urz.uni-heidelberg.de>.
10
11 groff is free software; you can redistribute it and/or modify it under
12 the terms of the GNU General Public License as published by the Free
13 Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
15
16 groff is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19 for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
23
24 ..
25 .
26 .if !d sopath \
27 .  ds sopath
28 .
29 .so \*[sopath]examples/common.roff
30 .
31 .time start
32 .
33 .nr *n 25
34 .nr *# 0 1
35 .
36 .de ctab
37 .  nr #cc 0
38 .  PN \\$1 \
39      ".nr #cc +(1f / \\$1)" \
40      ".defcolor \En[t*#] rgb \\$2 \\$3 \\$4" \
41      ".TBL csp=\n[t*l]/(12*\\$1+2) border= cpd=0 bgc=\\\\n[t*#] bc=" \
42        ".if (\\\\n+[*#] == 1) \
43           .CPTN Rainbow Colors \[em] Nested Tables with Colored Backgrounds \
44                 val=b" \
45        .TR \
46          .TD
47 ..
48 .
49 .ctab \n[*n] 1            0           \En[#cc]u      \" rot     -> magenta
50 .ctab \n[*n] 1-\En[#cc]u  0           1              \" magenta -> blue
51 .ctab \n[*n] 0            \En[#cc]u   1              \" blue    -> cyan
52 .ctab \n[*n] 0            1           1-\En[#cc]u    \" cyan    -> green
53 .ctab \n[*n] \En[#cc]u    1           0              \" green   -> yellow
54 .ctab \n[*n] 1            1-\En[#cc]u 0              \" yellow  -> red
55 .
56 .PN 6*\n[*n] .ETB
57 .
58 .time end
59 .
60 .bp
61 .
62 .time start
63 .
64 .nr *n 25
65 .nr *# 0 1
66 .
67 .de ctab
68 .  nr #cc 0
69 .  PN \\$1 \
70      ".nr #cc +(1f / \\$1)" \
71      ".defcolor \En[t*#] rgb \\$2 \\$3 \\$4" \
72      ".TBL border=\n[t*l]/(12*\\$1+2) csp=0 cpd=0 bc=\\\\n[t*#] bgc=" \
73        ".if (\\\\n+[*#] == 1) \
74           .CPTN Rainbow Colors \[em] Nested Tables with Colored Borders \
75                 val=b" \
76        .TR \
77          .TD
78 ..
79 .
80 .ctab \n[*n] 1            \En[#cc]u   0               \" red     -> yellow
81 .ctab \n[*n] 1-\En[#cc]u  1           0               \" yellow  -> green
82 .ctab \n[*n] 0            1           \En[#cc]u       \" green   -> cyan
83 .ctab \n[*n] 0            1-\En[#cc]u 1               \" cyan    -> blue
84 .ctab \n[*n] \En[#cc]u    0           1               \" blue    -> magenta
85 .ctab \n[*n] 1            0           1-\En[#cc]u     \" magenta -> red
86 .
87 .PN 6*\n[*n] .ETB
88 .
89 .time end
90 .
91 .\"     466MHz Celeron CPU, 384MB RAM 
92 .\"     WindowsXP/cygwin groff18.1:     11/10s
93 .\"     WindowsXP/cygwin groff19.2:     57/55s
94 .\"     Suse Linux 9.3 groff19.2:         8/8s