summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/brace.m4
blob: b0089fe96d71804789ffbdada9329fccea9c6bd0 (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
.PS
# brace.m4
gen_init
NeedDpicTools

divert(-1)
                               `bracket(linespec, end depth,
                                  thickness, end thickness, attributes)
                                Square bracket along linespec
                                default depth is linewid/5
                                attributes = eg
                                  thick 0.4 outlined "string" shaded "string"
                                  (default black)'
define(`bracket',`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1'))
 M4brS: last line.start; M4brE: last line.end
 [ brdepth = ifelse(`$2',,linewid/5,`($2)')
   brthick = ifelse(`$3',,brdepth/6,`($3)')
   endthick = ifelse(`$4',,brthick/3,`($4)')
   define(`m4brackattribs',
    `ifelse(`$5',,`thick 0.4 shaded rgbstring(0,0,0)',`$5')')dnl
   {line m4brackattribs \
     from M4brS+vec_(0,brdepth) to M4brS+vec_(0,brdepth+brthick) \
     then to M4brE+vec_(0,brdepth+brthick) \
     then to M4brE \
     then to M4brE+vec_(-endthick,0) \
     then to M4brE+vec_(-endthick,brdepth) \
     then to M4brS+vec_( endthick,brdepth) \
     then to M4brS+vec_( endthick,0) \
     then to M4brS \
     then to M4brS+vec_(0,brdepth) }
   S: M4brS
   ] with .S at Here')

                               `brace(linespec,depth,arm thickness,attributes)
                                Curly brace along linespec
                                default depth is linewid/5
                                attributes = eg
                                  thick 0.4 outlined "string" shaded "string"
                                  (default black)'
define(`brace',`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1'))
  M4brS: last line.start; M4brE: last line.end
  [ brdepth = ifelse(`$2',,linewid/5,`$2')
    brthick = ifelse(`$3',,brdepth/6,`$3')
    define(`m4braceattribs',
     `ifelse(`$4',,`thick 0.4 shaded rgbstring(0,0,0)',`$4')')dnl
    tension = 0.55
    halfwid = distance(M4brS,M4brE)
    smallrad = brdepth-brthick
    bigrad = brdepth+brthick
    for sgn=1 to -1 by -2 do {
      S: rvec_(sgn*halfwid/2,0)
      A: S+vec_(0,smallrad/2)
      B: vec_(0,smallrad/2)
      T: vec_(0,brdepth)
      C: vec_(0,bigrad/2)
      D: vec_(sgn*halfwid/2,bigrad/2)
      {spline tension m4braceattribs \
        from S to tension between S and A \
        then to tension between A-vec_(sgn*bigrad/2,0) and A \
        then to A-vec_(sgn*bigrad/2,0) \
        then to B+vec_(sgn*bigrad/2,0) \
        then to tension between B+vec_(sgn*bigrad/2,0) and B \
        then to tension between T and B \
        then to T \
        then to tension between T and C \
        then to tension between C+vec_(sgn*bigrad/2,0) and C \
        then to C+vec_(sgn*bigrad/2,0) \
        then to D-vec_(sgn*bigrad/2,0) \
        then to tension between D-vec_(sgn*bigrad/2,0) and D \
        then to tension between S and D \
        then to S }
      }
    E: (0,0)
] with .E at 0.5 between M4brS and M4brE')
divert(0)dnl

  del = 0.2
  maxht = 2
  minht = 0.3
  n = 16
  hmax = 360
R1: [
  for i=0 to n-1 do {
    x = i/n
    y = minht*(1-x)+maxht*x
    hsvtorgb(x*hmax,1,1,r,g,b)
    brace(from (    -i*del,-y/2)  up y,,,thick 0.4 shaded rgbstring(r,g,b))
    brace(from ((i+1)*del, y/2) down y,,,thick 0.4 \
      outlined rgbstring(r,g,b) shaded rgbstring(r,g,b))
    }
  ]
R2: [
  for i=0 to n-1 do {
    x = i/n
    y = minht*(1-x)+maxht*x
    hsvtorgb(x*hmax,1,1,r,g,b)
    brace(from (    -i*del,-y/2)  up y,5bp__+x*20bp__,2bp__+x*13bp__,thick 0.4 \
      shaded rgbstring(r,g,b))
    brace(from ((i+1)*del, y/2) down y,5bp__+x*20bp__,2bp__+x*13bp__,thick 0.4 \
      outlined rgbstring(r,g,b) shaded rgbstring(r,g,b))
    }
  ] with .n at R1.s+(0,-0.2)
R3: [
  for i=0 to n-1 do {
    x = i/n
    y = minht*(1-x)+maxht*x
    hsvtorgb(x*hmax,1,1,r,g,b)
    bracket(from (   -i*del,-y/2)   up y, 5bp__+x*20bp__, 2bp__+x*13bp__,,
      thick 0.4 shaded rgbstring(r,g,b))
    bracket(from ((i+1)*del, y/2) down y, 5bp__+x*20bp__, 2bp__+x*13bp__,,
      thick 0.4 outlined rgbstring(r,g,b) shaded rgbstring(r,g,b))
    }
  ] with .n at R2.s+(0,-0.2)

.PE