| 1 |
.PS |
| 2 |
# brace.m4 |
| 3 |
gen_init |
| 4 |
NeedDpicTools |
| 5 |
|
| 6 |
divert(-1) |
| 7 |
`bracket(linespec, end depth, |
| 8 |
thickness, end thickness, attributes) |
| 9 |
Square bracket along linespec |
| 10 |
default depth is linewid/5 |
| 11 |
attributes = eg |
| 12 |
thick 0.4 outlined "string" shaded "string" |
| 13 |
(default black)' |
| 14 |
define(`bracket',`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1')) |
| 15 |
M4brS: last line.start; M4brE: last line.end |
| 16 |
[ brdepth = ifelse(`$2',,linewid/5,`($2)') |
| 17 |
brthick = ifelse(`$3',,brdepth/6,`($3)') |
| 18 |
endthick = ifelse(`$4',,brthick/3,`($4)') |
| 19 |
define(`m4brackattribs', |
| 20 |
`ifelse(`$5',,`thick 0.4 shaded rgbstring(0,0,0)',`$5')')dnl |
| 21 |
{line m4brackattribs \ |
| 22 |
from M4brS+vec_(0,brdepth) to M4brS+vec_(0,brdepth+brthick) \ |
| 23 |
then to M4brE+vec_(0,brdepth+brthick) \ |
| 24 |
then to M4brE \ |
| 25 |
then to M4brE+vec_(-endthick,0) \ |
| 26 |
then to M4brE+vec_(-endthick,brdepth) \ |
| 27 |
then to M4brS+vec_( endthick,brdepth) \ |
| 28 |
then to M4brS+vec_( endthick,0) \ |
| 29 |
then to M4brS \ |
| 30 |
then to M4brS+vec_(0,brdepth) } |
| 31 |
S: M4brS |
| 32 |
] with .S at Here') |
| 33 |
|
| 34 |
`brace(linespec,depth,arm thickness,attributes) |
| 35 |
Curly brace along linespec |
| 36 |
default depth is linewid/5 |
| 37 |
attributes = eg |
| 38 |
thick 0.4 outlined "string" shaded "string" |
| 39 |
(default black)' |
| 40 |
define(`brace',`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1')) |
| 41 |
M4brS: last line.start; M4brE: last line.end |
| 42 |
[ brdepth = ifelse(`$2',,linewid/5,`$2') |
| 43 |
brthick = ifelse(`$3',,brdepth/6,`$3') |
| 44 |
define(`m4braceattribs', |
| 45 |
`ifelse(`$4',,`thick 0.4 shaded rgbstring(0,0,0)',`$4')')dnl |
| 46 |
tension = 0.55 |
| 47 |
halfwid = distance(M4brS,M4brE) |
| 48 |
smallrad = brdepth-brthick |
| 49 |
bigrad = brdepth+brthick |
| 50 |
for sgn=1 to -1 by -2 do { |
| 51 |
S: rvec_(sgn*halfwid/2,0) |
| 52 |
A: S+vec_(0,smallrad/2) |
| 53 |
B: vec_(0,smallrad/2) |
| 54 |
T: vec_(0,brdepth) |
| 55 |
C: vec_(0,bigrad/2) |
| 56 |
D: vec_(sgn*halfwid/2,bigrad/2) |
| 57 |
{spline tension m4braceattribs \ |
| 58 |
from S to tension between S and A \ |
| 59 |
then to tension between A-vec_(sgn*bigrad/2,0) and A \ |
| 60 |
then to A-vec_(sgn*bigrad/2,0) \ |
| 61 |
then to B+vec_(sgn*bigrad/2,0) \ |
| 62 |
then to tension between B+vec_(sgn*bigrad/2,0) and B \ |
| 63 |
then to tension between T and B \ |
| 64 |
then to T \ |
| 65 |
then to tension between T and C \ |
| 66 |
then to tension between C+vec_(sgn*bigrad/2,0) and C \ |
| 67 |
then to C+vec_(sgn*bigrad/2,0) \ |
| 68 |
then to D-vec_(sgn*bigrad/2,0) \ |
| 69 |
then to tension between D-vec_(sgn*bigrad/2,0) and D \ |
| 70 |
then to tension between S and D \ |
| 71 |
then to S } |
| 72 |
} |
| 73 |
E: (0,0) |
| 74 |
] with .E at 0.5 between M4brS and M4brE') |
| 75 |
divert(0)dnl |
| 76 |
|
| 77 |
del = 0.2 |
| 78 |
maxht = 2 |
| 79 |
minht = 0.3 |
| 80 |
n = 16 |
| 81 |
hmax = 360 |
| 82 |
R1: [ |
| 83 |
for i=0 to n-1 do { |
| 84 |
x = i/n |
| 85 |
y = minht*(1-x)+maxht*x |
| 86 |
hsvtorgb(x*hmax,1,1,r,g,b) |
| 87 |
brace(from ( -i*del,-y/2) up y,,,thick 0.4 shaded rgbstring(r,g,b)) |
| 88 |
brace(from ((i+1)*del, y/2) down y,,,thick 0.4 \ |
| 89 |
outlined rgbstring(r,g,b) shaded rgbstring(r,g,b)) |
| 90 |
} |
| 91 |
] |
| 92 |
R2: [ |
| 93 |
for i=0 to n-1 do { |
| 94 |
x = i/n |
| 95 |
y = minht*(1-x)+maxht*x |
| 96 |
hsvtorgb(x*hmax,1,1,r,g,b) |
| 97 |
brace(from ( -i*del,-y/2) up y,5bp__+x*20bp__,2bp__+x*13bp__,thick 0.4 \ |
| 98 |
shaded rgbstring(r,g,b)) |
| 99 |
brace(from ((i+1)*del, y/2) down y,5bp__+x*20bp__,2bp__+x*13bp__,thick 0.4 \ |
| 100 |
outlined rgbstring(r,g,b) shaded rgbstring(r,g,b)) |
| 101 |
} |
| 102 |
] with .n at R1.s+(0,-0.2) |
| 103 |
R3: [ |
| 104 |
for i=0 to n-1 do { |
| 105 |
x = i/n |
| 106 |
y = minht*(1-x)+maxht*x |
| 107 |
hsvtorgb(x*hmax,1,1,r,g,b) |
| 108 |
bracket(from ( -i*del,-y/2) up y, 5bp__+x*20bp__, 2bp__+x*13bp__,, |
| 109 |
thick 0.4 shaded rgbstring(r,g,b)) |
| 110 |
bracket(from ((i+1)*del, y/2) down y, 5bp__+x*20bp__, 2bp__+x*13bp__,, |
| 111 |
thick 0.4 outlined rgbstring(r,g,b) shaded rgbstring(r,g,b)) |
| 112 |
} |
| 113 |
] with .n at R2.s+(0,-0.2) |
| 114 |
|
| 115 |
.PE |