Debian Codegraph @

texmf-dist/doc/latex/circuit-macros/examples/extras/HSVS.m4

raw
1 .PS
2 # Shadow.m4
3 gen_init
4 NeedDpicTools
5 s_init(HSV)
6
7 divert(-1)
8 `shadowellipse(options,text)
9 Draws a shadowed ellipse
10 with gradient from white at the top to
11 hsv-specified color at the bottom
12 Default is uniform lightgray shade
13 Arg 2 is a text label written at the center'
14 define(`shadowellipse',`[ Orig: Here
15 m4shadow_keys(`$1')
16 [
17 ellipse wid m4wid ht m4ht invis shaded m4shadow ] wid 0 ht 0 \
18 at (m4shadowthick+m4thick bp__/2,-(m4shadowthick+m4thick bp__/2))
19 # at ((m4shadowthick)/2,-(m4shadowthick)/2)
20 ifelse(m4hue,,,`
21 define pElBshade { v = m4ht*($`'1)
22 if v < m4rad then { h = (m4wid/2-m4rad)+sqrt(m4rad^2-(m4rad-v)^2) } \
23 else { if v < m4ht-m4rad then { h = m4wid/2 } \
24 else { h = (m4wid/2-m4rad)+sqrt(m4rad^2-(m4rad-(m4ht-v))^2) } }
25 line from (-h,v) to (h,v) thick m4thick outlined rgbstring($`'2,$`'3,$`'4)
26 }
27 nsteps = rnd(m4ht/(m4thick bp__)*1.1)
28 hsvtorgb(m4hue,m4sat,m4val,r,g,b)
29 ShadeObject(pElBshade,nsteps,
30 0, r, g, b,
31 1, 1, 1, 1) with .c at Orig ')
32 Ellipse: ellipse ht m4ht wid m4wid thick m4thick outline m4outlined \
33 at Orig ifelse(m4hue,,shaded m4shaded)
34 ifelse(`$2',,,`m4lstring(`$2',"`$2'") at Ellipse')
35 `$3']')
36 `shadowbox(options,text) Draws a shadowed box
37 with gradient from white at the top to
38 hsv-specified color at the bottom
39 Default is uniform lightgray shade
40 Arg 2 is a text label written at the center'
41 define(`shadowbox',`[ Orig: Here
42 m4shadow_keys(`$1')
43 [
44 box invis rad m4rad ht m4ht wid m4wid shaded m4shadow ] wid 0 ht 0 \
45 at (m4shadowthick+m4thick bp__/2,-(m4shadowthick+m4thick bp__/2))
46 # box rad m4rad+m4thick bp__/2+m4shadowthick/2 ht m4ht wid m4wid \
47 # thick m4shadowthick/(1bp__) outlined m4shadow ] wid 0 ht 0 \
48 # at ((m4shadowthick+m4thick bp__)/2,-(m4shadowthick+m4thick bp__)/2)
49 ifelse(m4hue,,,`
50 define pBxBshade { v = m4ht*($`'1)
51 if v < m4rad then { h = (m4wid/2-m4rad)+sqrt(m4rad^2-(m4rad-v)^2) } \
52 else { if v < m4ht-m4rad then { h = m4wid/2 } \
53 else { h = (m4wid/2-m4rad)+sqrt(m4rad^2-(m4rad-(m4ht-v))^2) } }
54 line from (-h,v) to (h,v) thick m4thick outlined rgbstring($`'2,$`'3,$`'4)
55 }
56 nsteps = rnd(m4ht/(m4thick bp__)*1.1)
57 hsvtorgb(m4hue,m4sat,m4val,r,g,b)
58 ShadeObject(pBxBshade,nsteps,
59 0, r, g, b,
60 1, 1, 1, 1) with .c at Orig ')
61 Box: box rad m4rad ht m4ht wid m4wid thick m4thick outline m4outlined \
62 at Orig ifelse(m4hue,,shaded m4shaded)
63 ifelse(`$2',,,`m4lstring(`$2',"`$2'") at Box')
64 `$3']')
65 define(`m4shadow_keys',
66 # Box size parameters
67 `setkey_(`$1',ht,boxht)dnl
68 setkey_(`$1',wid,boxwid)dnl
69 setkey_(`$1',rad,boxht/8)dnl
70 setkey_(`$1',thick,linethick)dnl
71 # Shadow thickness
72 setkey_(`$1',shadowthick,2*lthick)dnl
73 # HSV color for gradient shading
74 setkey_(`$1',hue)dnl Default is blank for a shade fill;
75 setkey_(`$1',sat,1)dnl
76 setkey_(`$1',val,1)dnl
77 # Named colors
78 setkey_(`$1',shaded,"lightgray",N)dnl
79 setkey_(`$1',outlined,"gray",N)dnl
80 setkey_(`$1',shadow,"lightgray",N)dnl
81 ')
82
83 divert(0)dnl
84
85 w = 0.3
86 boxwid = w
87 dh = 30
88 # Hue from 0 to 360
89 T:[ for i=0 to 361 by dh do { shadowbox(hue=i) } ]
90 { s_box(hue=0) at T.w rjust; s_box(hue=360) at T.e ljust }
91 { for i=0 to 361 by dh do { s_box("%g",i) at T.nw+(w/2+i/dh*w,0) above } }
92 { s_box(hue) at T.n+(0,12bp__) above }
93
94 # Hue from 0 to 360; sat=0.5; val=0.5
95 Ta:[ for i=0 to 361 by dh do { shadowbox(hue=i;sat=0.5;val=0.5) } ] \
96 with .nw at last [].sw
97 { s_box(`\shortstack[r]{sat=0.5\\val=0.5}') at Ta.w rjust }
98
99 # Hue = 0; sat=0 to 1
100 U:[ for i=0 to 361 by dh do { shadowbox(hue=0;sat=i/360) } ] \
101 with .nw at last [].sw
102 { s_box(`\shortstack[r]{hue=0\\sat=0}') at U.w rjust
103 s_box(sat=1) at U.e ljust }
104
105 # Hue = 0; val=0 to 1
106 V:[ for i=0 to 361 by dh do { shadowbox(hue=0;val=i/360) } ] \
107 with .nw at last [].sw
108 { s_box(`\shortstack[r]{hue=0\\val=0}') at V.w rjust
109 s_box(val=1) at V.e ljust }
110
111 # Miscellaneous
112 W:[
113 shadowbox
114 DefineRGBColor(verylight,0.95,0.95,0.95); shadowbox(shaded=verylight)
115 shadowbox(hue=0;val=0)
116 DefineHSVColor(cx,110,0.5,0.5); shadowbox(shaded=cx)
117 shadowbox(shaded="yellow")
118 DefineHSVColor(lx,120,0.4,0.5); shadowbox(hue=120;sat=0.3;val=0.2;shadow=lx)
119 ] with .nw at last [].sw
120
121 ellipsewid = w
122 #linethick = 5
123 X:[
124 shadowellipse(shadowthick=lthick)
125 ellipse thick 5
126 ellipse thick 5 shaded "gray"
127 ] with .nw at last [].sw+(0,-0.1)
128
129 .PE