| 1 |
.PS |
| 2 |
# Gray_code.m4 |
| 3 |
gen_init |
| 4 |
|
| 5 |
GrayCode: [ |
| 6 |
outer = 4 |
| 7 |
inner = 0.75 |
| 8 |
nbits = 10 |
| 9 |
|
| 10 |
C: circle diam outer |
| 11 |
circle diam inner at C |
| 12 |
sectors = 2^nbits |
| 13 |
lthk = (outer-inner)/2/nbits |
| 14 |
for bit = 1 to nbits do { |
| 15 |
for is = 2^(bit-1) to sectors by 2^(bit+1) do { |
| 16 |
startang = is/sectors*360 |
| 17 |
endang = min(startang+(2^bit)/sectors*360,360) |
| 18 |
arcd(C,outer/2-(bit-0.5)*lthk,startang,endang) thick lthk/(1bp__) |
| 19 |
} |
| 20 |
} |
| 21 |
] |
| 22 |
Crossbar: [ |
| 23 |
#.PS |
| 24 |
# Crossbar switch |
| 25 |
#gen_init |
| 26 |
svg_font(sans-serif,11bp__) |
| 27 |
circlerad = 0.12 |
| 28 |
boxwid = 0.18 |
| 29 |
boxht = 0.18 |
| 30 |
rathick = 1.5 |
| 31 |
rawd = rathick*4 bp__ |
| 32 |
raht = rawd*2 |
| 33 |
boxdist = boxwid*1.8 |
| 34 |
|
| 35 |
`define bcoord {($2,-($1))*boxdist}' |
| 36 |
`define redarrow { arrow ht raht wid rawd thick rathick color "red" }' |
| 37 |
|
| 38 |
`define cbx {' |
| 39 |
thinlines_ |
| 40 |
n = $+ - 1 |
| 41 |
for i=0 to n do { |
| 42 |
line color "blue" from bcoord(i,0) to bcoord(i,n) |
| 43 |
line color "blue" from bcoord(0,i) to bcoord(n,i) |
| 44 |
C[i]: circle invis at bcoord(i,-1.5) |
| 45 |
} |
| 46 |
for i=0 to n do { |
| 47 |
exec sprintf("col = $%g",i+1) |
| 48 |
redarrow from C[i].e right 1.25*boxwid |
| 49 |
redarrow from C[i].w+(-boxwid,0) right raht |
| 50 |
for j=0 to n do { |
| 51 |
B: box color "blue" shaded "yellow" at bcoord(i,j) |
| 52 |
if j==col then { |
| 53 |
line color "blue" from B.s to B.e |
| 54 |
line thick rathick color "red" from C[i].e to B.w \ |
| 55 |
then to B.n then to (B.x,C[0].y+(2+j*2/3)*boxht) |
| 56 |
continue to (C[j].x-(2+j*2/3)*boxht,Here.y) |
| 57 |
continue to (Here,C[j]) then to C[j].w |
| 58 |
} \ |
| 59 |
else { |
| 60 |
line color "blue" from B.n to B.s |
| 61 |
line color "blue" from B.w to B.e |
| 62 |
} |
| 63 |
} |
| 64 |
} |
| 65 |
thicklines_ |
| 66 |
for i=0 to n do { |
| 67 |
circle thick 1.5 outlined "blue" shaded "yellow" at C[i] \ |
| 68 |
sprintf("ifpostscript(,ifsvg(,\large))%g",i) |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
[ |
| 73 |
cbx(3,6,0,5,2,7,1,4) |
| 74 |
] at 4,4 |
| 75 |
|
| 76 |
command "</g>" # end font |
| 77 |
#.PE |
| 78 |
] with .w at last [].e+(0.25,0) |
| 79 |
.PE |