| 1 |
.PS |
| 2 |
# Buttons.m4 |
| 3 |
gen_init |
| 4 |
NeedDpicTools |
| 5 |
|
| 6 |
divert(-1) |
| 7 |
################################################################# |
| 8 |
|
| 9 |
`RoundButton(diameter,hue,linedensity) |
| 10 |
hue 0=red, 60=yellow, 120=green ...' |
| 11 |
define(`RoundButton',`[ |
| 12 |
# Colors and radius: |
| 13 |
hue = ifelse(`$2',,60,`$2') |
| 14 |
crad = ifelse(`$1',,circlerad,(`$1')/2) |
| 15 |
linedensity = ifelse(`$3',,150/scale,`$3') # default 150 lines per inch |
| 16 |
hsvtorgb(hue, 1, 1, r1,g1,b1) |
| 17 |
hsvtorgb(hue-5, 1,0.9, r2,g2,b2) |
| 18 |
hsvtorgb(hue-10,1,0.5, r3,g3,b3) |
| 19 |
# Shaded main disk |
| 20 |
define RBbackground { |
| 21 |
circle rad crad*($`'1) thick lthk at C outlined rgbstring($`'2,$`'3,$`'4) |
| 22 |
} |
| 23 |
C: circle invis rad crad at (0,0) |
| 24 |
nsteps = round_(crad*linedensity) |
| 25 |
lthk = crad/nsteps/(1bp__) |
| 26 |
ShadeObject(RBbackground,nsteps, |
| 27 |
0, r1,g1,b1, |
| 28 |
0.2, r1,g1,b1, |
| 29 |
0.8, r2,g2,b2, |
| 30 |
1, r3,g3,b3) at C |
| 31 |
# Highlight disk with arc shading |
| 32 |
rad1 = crad*3/4 |
| 33 |
C1: C.n-(0,rad1+0.02*crad) |
| 34 |
C2: C1+(0,2*rad1) |
| 35 |
lthk = 2*rad1/nsteps/(1bp__) |
| 36 |
define RBoverlay { |
| 37 |
radx = rad1 + ($`'1)*2*rad1 |
| 38 |
if $`'1 < 1 then { |
| 39 |
arc cw rad radx thick lthk outlined rgbstring($`'2,$`'3,$`'4) \ |
| 40 |
from Cintersect(C2,radx,C1,rad1) \ |
| 41 |
to Cintersect(C2,radx,C1,rad1,R) \ |
| 42 |
with .c at C2 |
| 43 |
} } |
| 44 |
nsteps = round_(rad1*2*linedensity) |
| 45 |
ShadeObject(RBoverlay,nsteps, |
| 46 |
0, 1, 1, 1, |
| 47 |
0.1, 1, 1, 1, |
| 48 |
0.33,(r1+r2)/2,(g1+g2)/2,(b1+b2)/2, |
| 49 |
0.67,r1,g1,b1, |
| 50 |
1, (r1+r2)/2,(g1+g2)/2,(b1+b2)/2) with .c at C1 |
| 51 |
`$4']') |
| 52 |
|
| 53 |
################################################################# |
| 54 |
|
| 55 |
`BoxButton(wid,height,hue,linedensity) |
| 56 |
hue 0=red, 60=yellow, 120=green ...' |
| 57 |
define(`BoxButton',`[ |
| 58 |
# Size and Color |
| 59 |
boxw = ifelse(`$1',,boxwid*4/3,`$1') |
| 60 |
boxh = ifelse(`$2',,boxw/4,`$2') |
| 61 |
hue = ifelse(`$3',,180,`$3') |
| 62 |
hsvtorgb(hue, 1, 1, r1,g1,b1) |
| 63 |
hsvtorgb(hue-5, 1,0.9, r2,g2,b2) |
| 64 |
hsvtorgb(hue-10,1,0.5, r3,g3,b3) |
| 65 |
# Peripheral shading |
| 66 |
linedensity = ifelse(`$4',,150/scale,`$4') |
| 67 |
nsteps=10 |
| 68 |
define BxBshadow { |
| 69 |
B: box ht boxh wid boxw rad boxh/2 \ |
| 70 |
outlined rgbstring($`'2,$`'3,$`'4) at (0,($`'1)*4*linethick bp__) |
| 71 |
} |
| 72 |
Q: ShadeObject(BxBshadow,nsteps, |
| 73 |
0, 1,1,1, |
| 74 |
1, r3,g3,b3) |
| 75 |
# Shaded body |
| 76 |
C: ColoredV(box, |
| 77 |
(( 0,r1,g1,b1, 0.45,r2,g2,b2, 1,r3,g3,b3)):boxh/(Q.B.thick bp__)*2, |
| 78 |
wid boxw ht boxh rad boxh/2 invis) with .n at Q.n |
| 79 |
# Shaded highlight |
| 80 |
bh = boxht*0.4 |
| 81 |
ColoredV(box,((0,1,1,1, 8/(bh*linedensity),1,1,1, 1,r2,g2,b2)), |
| 82 |
ht bh wid boxw*4/4.5 rad bh/2 invis) \ |
| 83 |
with .n at Q.n+(0,-boxh/20) |
| 84 |
`$5']') |
| 85 |
|
| 86 |
################################################################# |
| 87 |
divert(0)dnl |
| 88 |
|
| 89 |
for x=0 to 5 do { |
| 90 |
B: RoundButton(0.6,x*60) at (x,0) |
| 91 |
"Button" sprintf("%g",x+1) at B } |
| 92 |
|
| 93 |
[ for i=0 to 2 do { |
| 94 |
BoxButton(1.5,,180+120*i) at (i*2,0) |
| 95 |
"Button" at last [].C |
| 96 |
} |
| 97 |
] with .nw at 1st [].sw+(0,-0.5) |
| 98 |
|
| 99 |
.PE |