diff options
author | Norbert Preining <norbert@preining.info> | 2020-02-18 03:02:28 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-02-18 03:02:28 +0000 |
commit | bb5325dae4202b519b7210a338651301e048998d (patch) | |
tree | 4caa8d8c62275cb193df85d10f8f0e10bab587b3 /graphics/circuit_macros/examples/svg | |
parent | 67394fd2cfa6167f7e2316237629bec93851c1fb (diff) |
CTAN sync 202002180302
Diffstat (limited to 'graphics/circuit_macros/examples/svg')
17 files changed, 725 insertions, 186 deletions
diff --git a/graphics/circuit_macros/examples/svg/AntiqueClockSVG.m4 b/graphics/circuit_macros/examples/svg/AntiqueClockSVG.m4 new file mode 100644 index 0000000000..0848a53cbe --- /dev/null +++ b/graphics/circuit_macros/examples/svg/AntiqueClockSVG.m4 @@ -0,0 +1,158 @@ +.PS +# AntiqueClockSVG.m4 +gen_init(svg_font(font-family="sans-serif" font-stretch="condensed")) + +# https://tex.stackexchange.com/questions/236923/generate-analog-clock-with-numbered-face-add-seconds-roman-numerals + +# `Initialize rotated text. Any unrotated text must +# appear after the rotated text.' +svgrot_init(AntiqueClockSVG) + +# `hms2deg(hr,min,sec) hr:min:sec to degrees +# blank arg1: degrees for minute hand +# blank arg1 and arg2: degrees for second hand' +define(`hms2deg',`ifelse(`$1',, + `ifelse(`$2',, + `(90-pmod(ifelse(`$3',,0,`$3'),60)/60*360)', + `(90-(pmod(`$2',60)/60 + pmod(ifelse(`$3',,0,`$3'),60)/60/60)*360)')', + `(90-(pmod(`$1',12) + pmod(ifelse(`$2',,0,`$2'),60)/60 + dnl + pmod(ifelse(`$3',,0,`$3'),60)/3600)/12*360)')') + +# `SecondHand(length,hr,min,sec)' +define(`SecondHand',`[ shsf = (`$1')/3.2 + C: Here + { L: rpoint_(to (Rect_(`$1',hms2deg(,,`$4')))) } + line thick 8*shsf to rvec_(`$1',0) + ]') + +# `AntiqueMinuteHand(length,hr,min,sec)' +define(`AntiqueMinuteHand',`[ mhsf = (`$1')/2.84 + L: rpoint_(to (Rect_(`$1',hms2deg(,`$3',`$4')))) + C: circle fill_(0) diam 0.47*mhsf at L.start + move to C + spline from rvec_(0,0.047*mhsf) \ + to rvec_(1.65*mhsf,0.11*mhsf) \ + then to rvec_(`$1',0.018*mhsf) \ + then to rvec_(`$1',-0.018*mhsf) \ + then to rvec_(1.65*mhsf,-0.11*mhsf) \ + then to rvec_(0,-0.047*mhsf) \ + shaded rgbstring(0,0,0) + ]') + +# `AntiqueHourHand(length,hr,min,sec)' +define(`AntiqueHourHand',`[ hhsf = (`$1')/2.2 + L: rpoint_(to (Rect_(`$1',hms2deg(`$2',`$3',`$4')))) + C: circle fill_(0) diam 0.6*hhsf at L.start + move to C + v = 0.25*hhsf + { line to rvec_(1.1*hhsf,0) thick 0.15/(1bp__)*hhsf } + C1: rvec_(1.25*hhsf,0) + d = `$1'-1.25*hhsf + q = 1bp__*hhsf + r1 = (d^2 + q^2 - v^2)/(v-q)/2 + tang = atan2((r1+q),d) + for i=0 to 3 do { + X[i]: C1+vec_(rect_(v, pi_+i/3*( tang-pi_))) + Y[i]: C1+vec_(rect_(v,-pi_+i/3*(-tang+pi_))) + } + n = 3 + for i=1 to 4 do { aa = -pi_+tang + i/4*(pi_/2-tang) + XX: (d,r1+q)+(rect_(r1,aa)) + n+=1; + X[n]: C1+vec_(XX.x, XX.y) + Y[n]: C1+vec_(XX.x,-XX.y) + } + m = n + for i= 0 to m do { n+=1; X[n]: Y[m-i] } + fitcurve(X,n,shaded rgbstring(0,0,0)) + ]') + +define(`AntiqueClock',`[ # h,m,s,diam +# Clock size parameters: + hour = ifelse(`$1',,3,`$1') + minute = ifelse(`$2',,41,`$2') + second = ifelse(`$3',,51,`$3') + # outer radius + ifelse(`$4',,`skale=0.5; r1=2',`r1=(`$4')/2; skale=r1/4') + r2 = r1-0.5*skale + r3 = r2-0.14*skale + r4 = r3 - 0.35*skale + r5 = r4 - 0.17*skale + r6 = r5 - 0.63*skale + r7 = r6 - 0.17*skale + shadelinethick = 1.0 + +C: circle thick 0.2 rad r1 + +define shadeline { + s = 1-($`'1)*2 + v = r*s + h = sqrt(r^2-v^2) + t = 1-abs(s) + line from (vrot_(-h,v,cost,sint)) to (vrot_(h,v,cost,sint)) \ + thick shadelinethick outlined rgbstring(t,t,t) + } + + r = r1 # Bezel outer + nlines = int(2*r/(shadelinethick pt__)*1.1) + cost = cosd(10); sint = sind(10); + ShadeObject(shadeline,nlines, 0, 0,0,0, 0.5, 1,1,1, 1, 0,0,0 ) at C + + r = r2 # Bezel inner + nlines = int(2*r/(shadelinethick pt__)*1.1) + cost = cosd(-10); sint = sind(-10); + ShadeObject(shadeline,nlines, 0, 0,0,0, 0.25, 0.8,0.8,0.8, 0.5, 1,1,1, + 0.75, 0.8,0.8,0.8, 1, 0,0,0 ) at C + +# Clock face +Face: circle thick 0 fill_(1) rad r3 at C + circle rad r4 at C + circle rad r5 at C + circle rad r6 at C + circle rad r7 at C +# Ad hoc shift of rotated SVG text + define adj { (-cosd($`'1)*textht*0.5*sign(180-($`'1)),\ + (0.25+0.25*cosd(2*($`'1)))*textht) } +# Outer numbers + textht = (r3-r4)*0.6 + for mn = -15 to 15 by 5 do { t = 90-mn/60*360 + R:(Rect_((r3+r4)/2,t)) + svg_rot(mn/60*360,sprintf("%g",pmod(mn,60)) at C+R+adj(t)) + } + for mn = 20 to 40 by 5 do { t = 450-mn/60*360 + R: (Rect_((r3+r4)/2,t)) + svg_rot(-180+mn/60*360, sprintf("%g",pmod(mn,60)) at C+R+adj(t)) + } +# Outer tics + for mn = 1 to 60 do { t = 90-mn/60*360 + line from C+(Rect_(r5,t)) to C+(Rect_(r4,t)) } + +# Inner numbers + textht = (r5-r6)*0.6 + Loopover_(`mx',`tt = 90-(m4Lx-4)/12*360 + R: (Rect_((r5+r6)/2,tt)) + svg_rot(90-tt, "mx" at C+R+adj(tt)) ', + IX,X,XI,XII,I,II,III) + Loopover_(`mx',`tt = 360-m4Lx*30 + R: (Rect_((r5+r6)/2,tt)) + svg_rot(270-tt, "mx" at C+R+adj(tt)) ', + IV,V,VI,VII,VIII) + +# Inner tics + for mn = 5 to 60 by 5 do { t = 90-mn/60*360 + line from C+(Rect_(r7,t)) to C+(Rect_(r6,t)) } + +# Hands + AntiqueHourHand(r6,hour,minute,second) with .C at C + AntiqueMinuteHand(r5,hour,minute,second) with .C at C + SecondHand((r3+r4)/2,hour,minute,second) with .C at C + +# Center + dot(at C,0.1/4*r1,1) + ]') + + Clock1: AntiqueClock(,,,3.5) +# Clock2: AntiqueClock(4,48,07,2) at Clock1.e+(1.5,0) + + command "</g>" # end font +.PE diff --git a/graphics/circuit_macros/examples/svg/BtreeSVG.m4 b/graphics/circuit_macros/examples/svg/BtreeSVG.m4 index df0a2726b2..312249605e 100644 --- a/graphics/circuit_macros/examples/svg/BtreeSVG.m4 +++ b/graphics/circuit_macros/examples/svg/BtreeSVG.m4 @@ -2,7 +2,7 @@ # Btree.m4 # One way to draw a binary tree using pic macros gen_init(svg_font(sans-serif,11bp__)) -circlerad = 0.35 +circlerad = 0.30 define n { [C: circle fill_(0.9) $1 if "$2" != "" then { diff --git a/graphics/circuit_macros/examples/svg/ContactSVG.m4 b/graphics/circuit_macros/examples/svg/ContactSVG.m4 new file mode 100644 index 0000000000..057f702731 --- /dev/null +++ b/graphics/circuit_macros/examples/svg/ContactSVG.m4 @@ -0,0 +1,101 @@ +.PS +# ContactSVG +cct_init +svg_font(sans-serif,11bp__) + +movw = 0.45 +{ + contact + {S:"svg_tt(`contact')" at last [].s+(0,-0.15) + "svg_it(`P')" rjust at last [].P.w + "svg_it(`O')" ljust at last [].O + "svg_it(`C')" ljust at last [].C } + move right_ movw; contact(R) + {"svg_tt(`(R)')" at (last [].s,S) + "svg_it(`P')" rjust at last [].P.w + "svg_it(`O')" ljust at last [].O + "svg_it(`C')" ljust at last [].C } + move right_ movw; contact(O); {"svg_tt(`(O)')" at (last [],S)} + move right_ movw; contact(C); {"svg_tt(`(C)')" at (last [],S)} + + move right_ movw; contact(P) + {S: "svg_tt(`(P)')" at last [].s+(0,-0.15) + "svg_it(`P')" rjust at last [].P.w + "svg_it(`O')" ljust at last [].O + "svg_it(`C')" ljust at last [].C } + move right_ movw; contact(PR) + {S: "svg_tt(`(PR)')" at last [].s+(0,-0.15) + "svg_it(`P')" rjust at last [].P.w + "svg_it(`O')" ljust at last [].O + "svg_it(`C')" ljust at last [].C } + move right_ movw; contact(PO); {"svg_tt(`(PO)')" at (last [],S)} + {"svg_it(`O')" ljust at last [].O + "svg_it(`C')" ljust at last [].C } + move right_ movw; contact(PC); {"svg_tt(`(PC)')" at (last [],S)} +} + +move down 0.75; right_ ; { + contact(I); {S: "svg_tt(`(I)')" at last [].s+(0,-12bp__) + "svg_it(`P')" rjust at last [].P.w + "svg_it(`O')" ljust at last [].O.e + "svg_it(`C')" ljust at last [].C.e } + move right_ movw; contact(RI) + {"svg_tt(`(RI)')" at (last [],S) + "svg_it(`P')" rjust at last [].P.w + "svg_it(`O')" ljust at last [].O.e + "svg_it(`C')" ljust at last [].C.e } + move right_ movw; contact(OI); {"svg_tt(`(OI)')" at (last [],S)} + move right_ movw; contact(CI); {"svg_tt(`(CI)')" at (last [],S)} + + move right_ movw; contact(PI); {"svg_tt(`(PI)')" at (last [],S) } + {"svg_it(`O')" ljust at last [].O.e + "svg_it(`C')" ljust at last [].C.e } + move right_ movw; contact(PIO); {"svg_tt(`(PIO)')" at (last [],S) } + move right_ movw; contact(PIC); {"svg_tt(`(PIC)')" at (last [],S) } +} + +movewid = movw + move down 0.65; right_; { + K: contact(T) + {S: "svg_tt(`(T)')" at last [].s+(0,-0.15) + thinlines_ + spline <- right 0.09 then up 0.05 right 0.05 from K.C; "svg_it(`C')" + spline <- right 0.09 then down 0.05 right 0.05 from K.O; "svg_it(`O')" + thicklines_ } + move; K: contact(RT) + {"svg_tt(`(RT)')" at (last [],S) + thinlines_ + spline <- right 0.09 then up 0.05 right 0.05 from K.O; "svg_it(`O')" + spline <- right 0.09 then down 0.05 right 0.05 from K.C; "svg_it(`C')" + thicklines_ } + move; contact(OT); {S: "svg_tt(`(OT)')" at (last [],S) } + move; contact(CT); {S: "svg_tt(`(CT)')" at (last [],S) } + move; contact(PT); {S: "svg_tt(`(PT)')" at (last [],S) } + move; contact(PTO); {S: "svg_tt(`(PTO)')" at (last [],S) } + move; contact(PTC); {S: "svg_tt(`(PTC)')" at (last [],S) } +} + + move down 0.65; right_; { + K: contact(U) + {S: "svg_tt(`(U)')" at last [].s+(0,-0.15) + thinlines_ + spline <- right 0.09 then up 0.05 right 0.05 from K.C; "svg_it(`C')" + spline <- right 0.09 then down 0.05 right 0.05 from K.O; "svg_it(`O')" + thicklines_ } + move; K: contact(RU) + {"svg_tt(`(RU)')" at (last [],S) + thinlines_ + spline <- right 0.09 then up 0.05 right 0.05 from K.O; "svg_it(`O')" + spline <- right 0.09 then down 0.05 right 0.05 from K.C; "svg_it(`C')" + thicklines_ } + move; K: contact(OU); {S: "svg_tt(`(OU)')" at (last [],S) + "svg_it(`O')" ljust at K.O.e } + move; K: contact(CU); {S: "svg_tt(`(CU)')" at (last [],S) + "svg_it(`C')" ljust at K.C.e } + move; contact(PU); {S: "svg_tt(`(PU)')" at (last [],S) } + move; contact(PUO); {S: "svg_tt(`(PUO)')" at (last [],S) } + move; contact(PUC); {S: "svg_tt(`(PUC)')" at (last [],S) } +} + + command "</g>" # end font +.PE diff --git a/graphics/circuit_macros/examples/svg/ContactsSVG.m4 b/graphics/circuit_macros/examples/svg/ContactsSVG.m4 new file mode 100644 index 0000000000..556ae04a61 --- /dev/null +++ b/graphics/circuit_macros/examples/svg/ContactsSVG.m4 @@ -0,0 +1,49 @@ +.PS +# ContactsSVG.m4 +cct_init +svg_font(sans-serif,10bp__) + + space = 0.75 + KS:contacts(2) + {"svg_tt(`contacts(2)')" wid 1 at KS.s +(0,-12bp__) + for_(1,2,1, + `"svg_it(P`'m4x)" rjust at last [].P`'m4x-(dotrad_,0) + "svg_it(O`'m4x)" ljust at last [].O`'m4x+(dotrad_,0) + "svg_it(C`'m4x)" ljust at last [].C`'m4x+(dotrad_,0) ') } + + KS:contacts(2,I) with .sw at last [].se+(space,0) + {"svg_tt(`(2,I)')" at KS.s +(0,-12bp__) + for_(1,2,1, + `"svg_it(P`'m4x)" rjust at last [].P`'m4x-(dotrad_,0) + "svg_it(O`'m4x)" ljust at last [].O`'m4x+(dotrad_,0) + "svg_it(C`'m4x)" ljust at last [].C`'m4x+(dotrad_,0) ') } + + KS:contacts(2,IO) with .sw at last [].se+(space,0) + {"svg_tt(`(2,IO)')" at KS.s +(0,-12bp__) + for_(1,2,1, + `"svg_it(P`'m4x)" rjust at last [].P`'m4x-(dotrad_,0) + "svg_it(O`'m4x)" ljust at last [].O`'m4x+(dotrad_,0) ') } + + KS:contacts(2,PICD) with .sw at last [].se+(space,0) + {"svg_tt(`(2,PICD)')" at KS.s +(0,-12bp__) + for_(1,2,1, + `"svg_it(P`'m4x)" rjust at last [].P`'m4x-(dotrad_,0) + "svg_it(O`'m4x)" ljust at last [].O`'m4x+(dotrad_,0) + "svg_it(C`'m4x)" ljust at last [].C`'m4x+(dotrad_,0) ') } + + KS:contacts(2,PTCD) with .sw at last [].se+(space,0) + {"svg_tt(`(2,PTCD)')" at KS.s +(0,-12bp__) + for_(1,2,1, + `"svg_it(P`'m4x)" rjust at last [].P`'m4x-(dotrad_,0) + "svg_it(O`'m4x)" ljust at last [].O`'m4x+(dotrad_,0) + "svg_it(C`'m4x)" ljust at last [].C`'m4x+(dotrad_,0) ') } + + KS:contacts(2,PUCD) with .sw at last [].se+(space,0) + {"svg_tt(`(2,PUCD)')" at KS.s +(0,-12bp__) + for_(1,2,1, + `"svg_it(P`'m4x)" rjust at last [].P`'m4x-(dotrad_,0) + "svg_it(O`'m4x)" ljust at last [].O`'m4x+(dotrad_,0) + "svg_it(C`'m4x)" ljust at last [].C`'m4x+(dotrad_,0) ') } + + command "</g>" # end font +.PE diff --git a/graphics/circuit_macros/examples/svg/CrowSVG.m4 b/graphics/circuit_macros/examples/svg/CrowSVG.m4 index 6be0938947..3fe2e8ff72 100644 --- a/graphics/circuit_macros/examples/svg/CrowSVG.m4 +++ b/graphics/circuit_macros/examples/svg/CrowSVG.m4 @@ -33,22 +33,22 @@ define boxtext { boxwid = boxwid*1.15 boxsep = boxwid/2 - custombox(Class,ht boxht*2.2, + custombox(Class,ht boxht*1.7, `classkey, class_type, class_desc') custombox(Product,ht Class.ht with .nw at Class.ne+(boxsep,0), `classkey, prodkey, prod_name, pkg_type') - custombox(Sales,ht boxht*3.3 with .nw at Product.ne+(boxsep*2,15pt__), + custombox(Sales,ht boxht*2.75 with .nw at Product.ne+(boxsep*2,13pt__), `perkey, classkey, prodkey, storekey, promokey, quantity, dollars') custombox(Period,ht Sales.ht with .nw at Sales.ne+(boxsep*2,0), `perkey, date, day, week, month, qtr, year') - custombox(Market,ht Sales.ht with .nw at Class.sw+(0,-boxsep*2), + custombox(Market,ht Sales.ht with .nw at Class.sw+(0,-boxsep*3/2), `perkey, date, day, week, month, qtr, year') - custombox(Store,ht boxht*3.6 with .sw at (Product.w,Market.s), + custombox(Store,ht boxht*3.2 with .sw at (Product.w,Market.s), `storekey, mktkey, store_type, store_name, street, city, state, zip') custombox(Promotion,ht Market.ht with .sw at (Period.w,Market.s), @@ -61,7 +61,7 @@ define boxtext { T: last line.c+(0,-crow_wd*2.5) move to Period.nw+(0,-10pt__); crowline(to (Sales.e,Here),,1.75*crow_wd) -Q: (last line.c,0.4 between Sales.se and Sales.ne) +Q: (last line.c,0.35 between Sales.se and Sales.ne) move to Market.ne+(0,-10pt__); crowline(to (Store.w,Here)) move to Store.ne+(0,-10pt__); line to (T,Here) then to T diff --git a/graphics/circuit_macros/examples/svg/DiniSVG.m4 b/graphics/circuit_macros/examples/svg/DiniSVG.m4 new file mode 100644 index 0000000000..5631a4822f --- /dev/null +++ b/graphics/circuit_macros/examples/svg/DiniSVG.m4 @@ -0,0 +1,193 @@ +.PS +# Dini.m4 +# This diagram can be produced using, e.g. +# m4 pdf.m4 Dini.m4 | dpic -d > Dini.pdf + +threeD_init +NeedDpicTools +scale = 1.5 +[ + viewazimuth = 0 # View angles in degrees + viewelevation = 20 + setview(viewazimuth,viewelevation,0) + + a = 1.5 + b = 0.25 + +define(`Dini', +`a*cos(`$1')*sin(`$2'),dnl + a*sin(`$1')*sin(`$2'),dnl + (a*(cos(`$2')+loge(tan((`$2')/2))) + b*(`$1'))') + + umin = 0; umax = 4*pi_ + vmin = 0.2; vmax = 2.0 + ugrid = 80; vgrid = 20 + + ur = umax-umin + vr = vmax-vmin +`define cu {umin+($1)/ugrid*ur}' +`define cv {vmin+($1)/vgrid*vr}' + +# Generate points and sort + n = -1 + for iu=0 to ugrid do { + for iv=0 to vgrid do { + n +=1 + ciu[n] = cu(iu) + civ[n] = cv(iv) + d[n] = dot3D(View3D,Dini(ciu[n],civ[n])) + ix[n] = n + } + } + dpquicksort(d,0,n,ix) + +# Draw the facets + linethick = 0.4 + du = ur/ugrid/2 + dv = vr/vgrid/2 + for i=0 to n do { + NE: project(Dini(ciu[ix[i]]+du,civ[ix[i]]+dv)) + SE: project(Dini(ciu[ix[i]]+du,civ[ix[i]]-dv)) + SW: project(Dini(ciu[ix[i]]-du,civ[ix[i]]-dv)) + NW: project(Dini(ciu[ix[i]]-du,civ[ix[i]]+dv)) + f = (-cos(ciu[ix[i]])+1)/2 + g = ( sin(ciu[ix[i]])+1)/2 + line from NE to SE then to SW then to NW then to NE \ + outlined rgbstring(f,g,0) shaded rgbstring(f,g,0) +# outlined rgbstring(0,0.5,0) shaded rgbstring(f,g,0) + } +] +# Icosahedron.m4 +[ +#threeD_init +#NeedDpicTools + # Computing facets is complicated, so list them. + # 60 vertices: +define(`m4x',-1) + array2(v,m4inx,0, 0, 1.021) + array2(v,m4inx,0.4035482, 0, 0.9378643) + array2(v,m4inx,-0.2274644, 0.3333333, 0.9378643) + array2(v,m4inx,-0.1471226, -0.375774, 0.9378643) + array2(v,m4inx,0.579632, 0.3333333, 0.7715933) + array2(v,m4inx,0.5058321, -0.375774, 0.8033483) + array2(v,m4inx,-0.6020514, 0.2908927, 0.7715933) + array2(v,m4inx,-0.05138057, 0.6666667, 0.7715933) + array2(v,m4inx,0.1654988, -0.6080151, 0.8033483) + array2(v,m4inx,-0.5217096, -0.4182147, 0.7715933) + array2(v,m4inx,0.8579998, 0.2908927, 0.4708062) + array2(v,m4inx,0.3521676, 0.6666667, 0.6884578) + array2(v,m4inx,0.7841999, -0.4182147, 0.5025612) + array2(v,m4inx,-0.657475, 0.5979962, 0.5025612) + array2(v,m4inx,-0.749174, -0.08488134, 0.6884578) + array2(v,m4inx,-0.3171418, 0.8302373, 0.5025612) + array2(v,m4inx,0.1035333, -0.8826969, 0.5025612) + array2(v,m4inx,-0.5836751, -0.6928964, 0.4708062) + array2(v,m4inx,0.8025761, 0.5979962, 0.2017741) + array2(v,m4inx,0.9602837, -0.08488134, 0.3362902) + array2(v,m4inx,0.4899547, 0.8302373, 0.3362902) + array2(v,m4inx,0.7222343, -0.6928964, 0.2017741) + array2(v,m4inx,-0.8600213, 0.5293258, 0.1503935) + array2(v,m4inx,-0.9517203, -0.1535518, 0.3362902) + array2(v,m4inx,-0.1793548, 0.993808, 0.1503935) + array2(v,m4inx,0.381901, -0.9251375, 0.2017741) + array2(v,m4inx,-0.2710537, -0.9251375, 0.3362902) + array2(v,m4inx,-0.8494363, -0.5293258, 0.2017741) + array2(v,m4inx,0.8494363, 0.5293258, -0.2017741) + array2(v,m4inx,1.007144, -0.1535518, -0.06725804) + array2(v,m4inx,0.2241935, 0.993808, 0.06725804) + array2(v,m4inx,0.8600213, -0.5293258, -0.1503935) + array2(v,m4inx,-0.7222343, 0.6928964, -0.2017741) + array2(v,m4inx,-1.007144, 0.1535518, 0.06725804) + array2(v,m4inx,-0.381901, 0.9251375, -0.2017741) + array2(v,m4inx,0.1793548, -0.993808, -0.1503935) + array2(v,m4inx,-0.2241935, -0.993808, -0.06725804) + array2(v,m4inx,-0.8025761, -0.5979962, -0.2017741) + array2(v,m4inx,0.5836751, 0.6928964, -0.4708062) + array2(v,m4inx,0.9517203, 0.1535518, -0.3362902) + array2(v,m4inx,0.2710537, 0.9251375, -0.3362902) + array2(v,m4inx,0.657475, -0.5979962, -0.5025612) + array2(v,m4inx,-0.7841999, 0.4182147, -0.5025612) + array2(v,m4inx,-0.9602837, 0.08488134, -0.3362902) + array2(v,m4inx,-0.1035333, 0.8826969, -0.5025612) + array2(v,m4inx,0.3171418, -0.8302373, -0.5025612) + array2(v,m4inx,-0.4899547, -0.8302373, -0.3362902) + array2(v,m4inx,-0.8579998, -0.2908927, -0.4708062) + array2(v,m4inx,0.5217096, 0.4182147, -0.7715933) + array2(v,m4inx,0.749174, 0.08488134, -0.6884578) + array2(v,m4inx,0.6020514, -0.2908927, -0.7715933) + array2(v,m4inx,-0.5058321, 0.375774, -0.8033483) + array2(v,m4inx,-0.1654988, 0.6080151, -0.8033483) + array2(v,m4inx,0.05138057, -0.6666667, -0.7715933) + array2(v,m4inx,-0.3521676, -0.6666667, -0.6884578) + array2(v,m4inx,-0.579632, -0.3333333, -0.7715933) + array2(v,m4inx,0.1471226, 0.375774, -0.9378643) + array2(v,m4inx,0.2274644, -0.3333333, -0.9378643) + array2(v,m4inx,-0.4035482, 0, -0.9378643) + array2(v,m4inx,0, 0, -1.021) + + # 12 pentagons +undefine(`m4x') +array2(p,m4inx,0,3,8,5,1) +array2(p,m4inx,2,7,15,13,6) +array2(p,m4inx,4,10,18,20,11) +array2(p,m4inx,9,14,23,27,17) +array2(p,m4inx,12,21,31,29,19) +array2(p,m4inx,16,26,36,35,25) +array2(p,m4inx,22,32,42,43,33) +array2(p,m4inx,24,30,40,44,34) +array2(p,m4inx,28,39,49,48,38) +array2(p,m4inx,37,47,55,54,46) +array2(p,m4inx,41,45,53,57,50) +array2(p,m4inx,51,52,56,59,58) + + # 20 hexagons +undefine(`m4x') +array2(h,m4inx,0,1,4,11,7,2) +array2(h,m4inx,0,2,6,14,9,3) +array2(h,m4inx,1,5,12,19,10,4) +array2(h,m4inx,3,9,17,26,16,8) +array2(h,m4inx,5,8,16,25,21,12) +array2(h,m4inx,6,13,22,33,23,14) +array2(h,m4inx,7,11,20,30,24,15) +array2(h,m4inx,10,19,29,39,28,18) +array2(h,m4inx,13,15,24,34,32,22) +array2(h,m4inx,17,27,37,46,36,26) +array2(h,m4inx,18,28,38,40,30,20) +array2(h,m4inx,21,25,35,45,41,31) +array2(h,m4inx,23,33,43,47,37,27) +array2(h,m4inx,29,31,41,50,49,39) +array2(h,m4inx,32,34,44,52,51,42) +array2(h,m4inx,35,36,46,54,53,45) +array2(h,m4inx,38,48,56,52,44,40) +array2(h,m4inx,42,51,58,55,47,43) +array2(h,m4inx,48,49,50,57,59,56) +array2(h,m4inx,53,54,55,58,59,57) + + viewazimuth = -10 # View angles in degrees + viewelevation = 40 + setview(viewazimuth,viewelevation,0) + + n = 0 # Find and draw the visible hexagons + for i=1 to 20 do { # The normal is the line to the center + for_(1,3,1,`a[m4x] = (v[h[i,1],m4x] + v[h[i,4],m4x])/2') + if dot3D(View3D,a[1],a[2],a[3]) >= 0 then { n +=1; ih[n] = i } + } + for i=1 to n do { + for j=1 to 6 do { x[j]=h[ih[i],j] } + line from project((v[x[1],1]),(v[x[1],2]),(v[x[1],3]))\ + for_(2,6,1,`to project((v[x[m4x],1]),(v[x[m4x],2]),(v[x[m4x],3]))\')\ + to project((v[x[1],1]),(v[x[1],2]),(v[x[1],3])) thick 0.2 fill_(0.95) + } + m = 0 + for i=1 to 12 do { # Visible pentagons + for_(1,3,1,`a[m4x] = 0; for j=1 to 5 do { a[m4x] += v[p[i,j],m4x] }') + if dot3D(View3D,a[1]/5,a[2]/5,a[3]/5) >= 0 then { m +=1; ip[m] = i } + } + for i=1 to m do { + for j=1 to 5 do { x[j]=p[ip[i],j] } + line from project((v[x[1],1]),(v[x[1],2]),(v[x[1],3])) \ + for_(2,5,1,`to project((v[x[m4x],1]),(v[x[m4x],2]),(v[x[m4x],3]))\')\ + to project((v[x[1],1]),(v[x[1],2]),(v[x[1],3])) thick 0.2 fill_(0) + } +] scaled 2.5 with .sw at last [].se+(1,0) +.PE diff --git a/graphics/circuit_macros/examples/svg/Makefile b/graphics/circuit_macros/examples/svg/Makefile index 4d604dac40..5ee232a5ea 100644 --- a/graphics/circuit_macros/examples/svg/Makefile +++ b/graphics/circuit_macros/examples/svg/Makefile @@ -7,6 +7,7 @@ M4LIBS = svg.m4 SVGconfig.m4 DPIC = dpic #DPIC = $$HOME/dpic/bu*/p2c/ftp/dpic #DPIC = $$HOME/dpic/bu*/test/dpic +#DPIC = $$HOME/dpic/dev/p2c/ftp/dpic #DPIC = ../../../dpic/bison/dpic .SUFFIXES: .pic .svg .m4 @@ -20,11 +21,11 @@ DPIC = dpic CCTSVG = \ AdderSVG.svg AlogixSVG.svg ABlogixSVG.svg AmpTableSVG.svg AntennasSVG.svg \ - AudioSVG.svg \ + AntiqueClockSVG.svg \ AudioSVG.svg \ BipSVG.svg BtreeSVG.svg ByteSVG.svg ButtonsSVG.svg \ - CanLogicSVG.svg CctTableSVG.svg ConnSVG.svg CountingSVG.svg CrossbarSVG.svg \ - CrowSVG.svg CrullerSVG.svg CsourceSVG.svg \ - DecoderSVG.svg DemultiplexerSVG.svg DiodesSVG.svg DriveSVG.svg \ + CanLogicSVG.svg CctTableSVG.svg ConnSVG.svg ContactSVG.svg ContactsSVG.svg \ + CountingSVG.svg CrossbarSVG.svg CrowSVG.svg CrullerSVG.svg CsourceSVG.svg \ + DecoderSVG.svg DemultiplexerSVG.svg DiniSVG.svg DiodesSVG.svg DriveSVG.svg \ EmarrowsSVG.svg \ FlowSVG.svg FontsSVG.svg FusesSVG.svg GrayCodeSVG.svg GroundsSVG.svg \ HeadersSVG.svg HeathkitSVG.svg InclepsSVG.svg I2LSVG.svg JackSVG.svg \ @@ -42,8 +43,8 @@ CCTSVG = \ ex08SVG.svg ex09SVG.svg ex10SVG.svg ex11SVG.svg ex12SVG.svg \ ex15SVG.svg ex16SVG.svg ex17SVG.svg ex18SVG.svg ex21SVG.svg \ expSVG.svg fetSVG.svg graysurfSVG.svg lcctSVG.svg \ - pwrsupplySVG.svg quickSVG.svg randomSVG.svg recycleSVG.svg roseSVG.svg \ - sfgSVG.svg shapesSVG.svg paletteSVG.svg \ + pwrsupplySVG.svg quickSVG.svg randomSVG.svg recycleSVG.svg relaycoilSVG.svg \ + roseSVG.svg sfgSVG.svg shapesSVG.svg paletteSVG.svg \ thyristorSVG.svg ujtSVG.svg wormSVG.svg XORSVG.svg Np.svg examplesSVG.html: examplesSVG.htmx @@ -54,7 +55,9 @@ examplesSVG.html: examplesSVG.htmx SED = sed -e '/^\%/d' TEST = test -tst: $(TEST).pic +tst: + if test -f test.pic; then printf "\n\nUsage: make clean tst\n\n"; exit 1; fi + m4 $(M4LIBS) test.m4 | $(SED) > test.pic $(DPIC) -v $(TEST).pic > $(TEST).svg m4 $(M4LIBS) $(TEST).m4 | $(SED) > $(TEST).pic $(DPIC) -v $(TEST).pic > $(TEST).svg @@ -63,6 +66,7 @@ tst: $(TEST).pic make tstSVG.html test.pic: + if test -f test.pic ; then echo "Usage: make clean tst" ; fi m4 $(M4LIBS) test.m4 | $(SED) > test.pic tstSVG.html: tstSVG.htmx $(TEST).svg @@ -74,6 +78,13 @@ tstSVG.html: tstSVG.htmx $(TEST).svg xst: Incleps.png +AntiqueClockSVG.svg: + m4 $(M4LIBS) AntiqueClockSVG.m4 | sed -e '/^\%/d' > AntiqueClockSVG.pic + $(DPIC) -v AntiqueClockSVG.pic > AntiqueClockSVG.svg + m4 $(M4LIBS) AntiqueClockSVG.m4 | sed -e '/^\%/d' > AntiqueClockSVG.pic + $(DPIC) -v AntiqueClockSVG.pic > AntiqueClockSVG.svg + grep '<\!-- width' AntiqueClockSVG.svg | sed -e 's%<\!-- *%%' -e 's% *-->%%' > AntiqueClockSVG.siz + InclepsSVG.svg: InclepsSVG.m4 m4 $(M4LIBS) $*.m4 | sed -e '/^\%/d' > $*.pic $(DPIC) -v $*.pic > $*.svg diff --git a/graphics/circuit_macros/examples/svg/PconnSVG.m4 b/graphics/circuit_macros/examples/svg/PconnSVG.m4 index 066d397ca2..348a619317 100644 --- a/graphics/circuit_macros/examples/svg/PconnSVG.m4 +++ b/graphics/circuit_macros/examples/svg/PconnSVG.m4 @@ -24,8 +24,6 @@ P1: [ C3: pconnex(,ACF) with .w at last [].e+(0.2,0) `"(,ACF)"' at last [].s below - C4: pconnex(,P) with .w at last [].e+(0.2,0) - `"(,P)"' at (C4,last "") below C5: pconnex(U,D) with .w at last [].e+(0.2,0) `"(U,D)"' at last [].s below C6: pconnex(U,DF) with .w at last [].e+(0.2,0) @@ -37,7 +35,11 @@ P1: [ ] P2: [ - C9: pconnex(,G) + C4: pconnex(,P) + `"(,P)"' at last [].s below + C11: pconnex(,PF) with .w at last [].e+(0.2,0) + `"(,PF)"' at C11.s below + C9: pconnex(,G) with .w at C11.e+(0.2,0) `"(,G)"' at last [].s below C91: pconnex(,GF) with .w at last [].e+(0.2,0) `"(,GF)"' at last [].s below diff --git a/graphics/circuit_macros/examples/svg/RelaySVG.m4 b/graphics/circuit_macros/examples/svg/RelaySVG.m4 index df633176b0..f4b8152a50 100644 --- a/graphics/circuit_macros/examples/svg/RelaySVG.m4 +++ b/graphics/circuit_macros/examples/svg/RelaySVG.m4 @@ -1,80 +1,47 @@ .PS -# `Relay.m4' -cct_init(svg_font(sans-serif,11bp__)) - -{contact - {`"contact"' wid 0.8 at last [].s+(0,-0.2) - "svg_it(P)" rjust at last [].P.w - "svg_it(O)" ljust at last [].O - "svg_it(C)" ljust at last [].C } - move right_ 1.0; contact(R,) - {`"contact(,R)"' at last [].s+(0,-0.2) - "svg_it(P)" rjust at last [].P.w - "svg_it(O)" ljust at last [].O - "svg_it(C)" ljust at last [].C } - move right_ 1.0; contact(P) - {`"contact(P)"' at last [].s+(0,-0.2) - "svg_it(P)" rjust at last [].P.w - "svg_it(O)" ljust at last [].O - "svg_it(C)" ljust at last [].C } - move right_ 1.0; contact(O,); {`"contact(O,)"' at last [].s+(0,-0.2)} - move right_ 1.0; contact(C,); {`"contact(C,)"' at last [].s+(0,-0.2)} -} -move down 0.8 -right_ -{contact(I) - {`"contact(I)"' at last [].s+(0,-0.2) - "svg_it(P)" rjust at last [].P.w - "svg_it(O)" ljust at last [].O.e - "svg_it(C)" ljust at last [].C.e } - move right_ 1.0; contact(RI) - {`"contact(RI)"' at last [].s+(0,-0.2) - "svg_it(P)" rjust at last [].P.w - "svg_it(O)" ljust at last [].O.e - "svg_it(C)" ljust at last [].C.e } - move right_ 1.0; contact(PI) - {`"contact(PI)"' at last [].s+(0,-0.2) - "svg_it(P)" rjust at last [].P.w - "svg_it(O)" ljust at last [].O.e - "svg_it(C)" ljust at last [].C.e } - move right_ 1.0; contact(OI); {`"contact(OI)"' at last [].s+(0,-0.2)} - move right_ 1.0; contact(CI); {`"contact(CI)"' at last [].s+(0,-0.2) wid 1} -} -move down 1.3 -right_ -{ -relay - {"svg_it(V1)" rjust at last [].V1 +# RelaySVG +cct_init +svg_font(sans-serif,10bp__) + +skip = 1.1 + +R1:relay + {"svg_it(V1)" wid 0.16 rjust at last [].V1 "svg_it(V2)" ljust at last [].V2 - "svg_it(P1)" rjust at last [].P1.w + "svg_it(P1)" rjust at last [].P1-(dotrad_,0) "svg_it(O1)" ljust at last [].O1 "svg_it(C1)" ljust at last [].C1 } -`"relay"' at last [].s+(0,-0.2) -relay(2) with .sw at last [].sw+(1.2,0) + S: "svg_tt(`relay')" at last [].s+(0,-0.2) + +R5:relay(2,CTh) with .sw at last [].sw+(skip,0) + { for_(1,2,1,` + "svg_it(P`'m4x)" rjust at last [].P`'m4x-(dotrad_,0) + "svg_it(C`'m4x)" ljust at last [].C`'m4x ') } + "svg_tt((2,CTh))" at (last [],S) + +R4:relay(2,O) with .sw at last [].sw+(skip,0) + {for_(1,2,1,` + "svg_it(P1)" rjust at last [].P1-(dotrad_,0) + "svg_it(O`'m4x)" ljust at last [].O`'m4x ')} + "svg_tt((2,O))" at (last [],S) + +R3:relay(2,PIAX) with .sw at last [].sw+(skip,0) {"svg_it(V1)" rjust at last [].V1 - "svg_it(V2)" ljust at last [].V2 - "svg_it(P1)" rjust at last [].P1.w - "svg_it(O1)" ljust at last [].O1 - "svg_it(C1)" ljust below at last [].C1 - "svg_it(P2)" rjust at last [].P2.w - "svg_it(O2)" ljust at last [].O2 - "svg_it(C2)" ljust at last [].C2 } -`"relay(2)"' at last [].s+(0,-0.2) -relay(2,RPI) with .sw at last [].sw+(1.2,0) + "svg_it(V2)" rjust at last [].V2 + for_(1,2,1,` + "svg_it(P`'m4x)" rjust at last [].P`'m4x-(dotrad_,0) + "svg_it(O`'m4x)" ljust at last [].O`'m4x+(dotrad_,0) + "svg_it(C`'m4x)" ljust at last [].C`'m4x+(dotrad_,-2pt__) ') } + "svg_tt((2,PIAX))" at (last [],S) + +R2:relay(2,R) with .sw at last [].sw+(skip,0) {"svg_it(V1)" rjust at last [].V1 - "svg_it(V2)" ljust at last [].V2 - "svg_it(P1)" rjust at last [].P1.w - "svg_it(O1)" wid 0.2 ljust at last [].O1.e - "svg_it(C1)" wid 0.2 ljust at last [].C1.e+(0,2pt__) - "svg_it(P2)" rjust at last [].P2.w - "svg_it(O2)" wid 0.2 ljust at last [].O2.e+(0,-2pt__) - "svg_it(C2)" wid 0.2 ljust at last [].C2.e } -`"relay(2,RIP)"' at last [].s+(0,-0.2) -relay(2,O) with .sw at last [].sw+(1.2,0) -`"relay(2,O)"' at last [].s+(0,-0.2) -relay(2,CT) with .sw at last [].sw+(1.2,0) -`"relay(2,CT)"' at last [].s+(0,-0.2) -} + "svg_it(V2)" wid 0.2 ljust at last [].V2 + for_(1,2,1,` + "svg_it(P`'m4x)" rjust at last [].P`'m4x-(dotrad_,0) + "svg_it(O`'m4x)" ljust at last [].O`'m4x + "svg_it(C`'m4x)" ljust at last [].C`'m4x ') } + "svg_tt(`relay(2,R)')" at (last [],S) - command "</g>" # end font + command "</g>)" # end font .PE diff --git a/graphics/circuit_macros/examples/svg/ShiftRSVG.m4 b/graphics/circuit_macros/examples/svg/ShiftRSVG.m4 index 9c8aa65a1c..022f4ced9f 100644 --- a/graphics/circuit_macros/examples/svg/ShiftRSVG.m4 +++ b/graphics/circuit_macros/examples/svg/ShiftRSVG.m4 @@ -1,13 +1,14 @@ .PS # ShiftR.m4 log_init(svg_font(sans-serif,11*0.9bp__)) +textoffset = textht/6 define(`lg_plen',3) -define(`customFF', - `FlipFlopX(wid 10*L_unit ht FF_ht*L_unit,, - : S;NE:CK;: R, N:PR, :Q;;ifelse(`$1',1,:Q), N:CLR, - ifelse(`$1',1,line right 5bp__ at 2nd last ""+(-7bp__,4bp__)))') +define(`customFF',`FlipFlopX(wid 10*L_unit ht FF_ht*L_unit,, + :S;NE:CK;:R, N:PR, :Q;;ifelse(`$1',1,:Q), N:CLR,, + ifelse(`$1',1, + line right textht with .end at 2nd last ""+(-textoffset,0.4*textht)))') F0: customFF(1) @@ -21,7 +22,7 @@ define(`customFF', NCLR: NOT_gate(right T.x-Serial.x from (Serial,F0.S1.end),N) "CLEAR" at NCLR.start rjust - line left textht*2.3 from last ""+(-0.3,0.6)*textht + line left textht*5 from last ""+(-textoffset,0.8*textht) CLK: NOT_gate(right T.x-Serial.x from NCLR.start+(0,-BUF_ht*3/2*L_unit)) "CLOCK" at CLK.start rjust diff --git a/graphics/circuit_macros/examples/svg/SierpinskiSVG.m4 b/graphics/circuit_macros/examples/svg/SierpinskiSVG.m4 index 7fbf13bf15..08d7fab111 100644 --- a/graphics/circuit_macros/examples/svg/SierpinskiSVG.m4 +++ b/graphics/circuit_macros/examples/svg/SierpinskiSVG.m4 @@ -13,7 +13,7 @@ gen_init } } - r = 4 + r = 3 linethick = 0.2 #linethick = 1/2 /(1pt__) lw = linethick pt__ /2 @@ -35,20 +35,20 @@ gen_init define CayleyGraph { if $3 > 0 then { { line to Here+(cosd($2),sind($2))*($1) - exec sprintf("CayleyGraph(%g,%g,%g);",0.5*($1),$2,$3-1); } + exec sprintf("CayleyGraph(%g,%g,%g);", ($1)/2, $2, $3-1); } { line to Here+(cosd($2+90),sind($2+90))*($1) - exec sprintf("CayleyGraph(%g,%g,%g);",0.5*($1),$2+90,$3-1); } + exec sprintf("CayleyGraph(%g,%g,%g);", ($1)/2, $2+90, $3-1); } { line to Here+(cosd($2-90),sind($2-90))*($1) - exec sprintf("CayleyGraph(%g,%g,%g);",0.5*($1),$2-90,$3-1); } + exec sprintf("CayleyGraph(%g,%g,%g);", ($1)/2, $2-90, $3-1); } } } size = 2 depth = 6 for t=0 to 270 by 90 do { - line from (0,0) to (cosd(t),sind(t)); + line from (0,0) to (cosd(t),sind(t))*size/2; { exec sprintf("CayleyGraph(%g,%g,%g);",size/4,t,depth); } } - ] with .sw at last [].se+(-0.25,0) + ] scaled 3/4 with .sw at last [].se+(-0.25,0) .PE diff --git a/graphics/circuit_macros/examples/svg/SwitchesSVG.m4 b/graphics/circuit_macros/examples/svg/SwitchesSVG.m4 index 8808e5be27..04fc2f52c5 100644 --- a/graphics/circuit_macros/examples/svg/SwitchesSVG.m4 +++ b/graphics/circuit_macros/examples/svg/SwitchesSVG.m4 @@ -4,100 +4,116 @@ cct_init(svg_font(sans-serif,11bp__,2bp__)) textoffset = 3bp__ movewid = 0.25 -moveht = moveht*1.25 +# Row 1 right_; { - lswitch; rlabel(,"``lswitch''") + lswitch; {S:"svg_tt(`lswitch')" at last [].s+(0,-10bp__)} move right_ - lswitch(,,O); rlabel(,"`(,,O)'") + lswitch(,,O); {"svg_tt(`(,,O)')" at (last [],S)} move right_ - lswitch(,,C); rlabel(,"`(,,C)'") + lswitch(,,C); {"svg_tt(`(,,C)')" at (last [],S)} move right_ - lswitch(,,DA); rlabel(,"`(,,DA)'") + lswitch(,,DA); {"svg_tt(`(,,DA)')" at (last [],S)} move right_ - lswitch(,,DO); rlabel(,"`(,,DO)'") + lswitch(,,dDO); {"svg_tt(`(,,dDO)')" at (last [],S)} move right_ - lswitch(,,DC); rlabel(,"`(,,DC)'") + lswitch(,,uDC); {"svg_tt(`(,,uDC)')" at (last [],S)} } +# Row 2 move down; right_; { - lswitch(,,K); rlabel(,"`(,,K)'") + lswitch(,,K); {S:"svg_tt(`(,,K)')" at last [].s+(0,-10bp__)} move right_ - lswitch(,,KD); rlabel(,"`(,,KD)'") + lswitch(,,KD); {"svg_tt(`(,,KD)')" at (last [],S)} move right_ - lswitch(,,KOD); rlabel(,"`(,,KOD)'") + lswitch(,,KOD); {"svg_tt(`(,,KOD)')" at (last [],S)} move right_ - lswitch(,,KCD); rlabel(,"`(,,KCD)'") + lswitch(,,KCD); {"svg_tt(`(,,KCD)')" at (last [],S)} move right_ - bswitch; rlabel(,"``bswitch''") + bswitch; {"svg_tt(``bswitch'')" at (last [],S)} move right_ - bswitch(,,C); rlabel(,"`(,,C)'") + bswitch(,,C); {"svg_tt(`(,,C)')" at (last [],S)} } +# Row 3 move down; right_; { - S: dswitch(,,) - ifgpic(`{[line invis] at S.c+(0,-0.2)}') - rlabel(,"``dswitch=''") - { "`switch(,,,D)'" at last [].s + (0,-0.23) } - thinlines_ - { spline <- from 0.25 along_(S) up 0.1 then up 0.05 left 0.1 - "W" wid 8bp__ at Here+(-5bp__,0) - spline <- from S.c+(0,m4sc*2) up 0.1 then up 0.05 left 0.1 - "B" wid 5bp__ at Here+(-5bp__,0) } - thicklines_ - move right_ - S: dswitch(,,WdBK); rlabel(,"`(,,WdBK)'") - thinlines_ - { spline <- from tr_xy(0,-2) up 0.1 then up 0.10 left 0.1 - "dB" rjust - spline <- from tr_xy(4,-2) right 0.1 then right 0.05 up 0.15 - "K" above } - thicklines_ - move right_ - dswitch(,,WBuD); rlabel(,"`(,,WBuD)'") - move right_ - dswitch(,,WdBKF); rlabel(,"`(,,WdBKF)'") - move right_ - dswitch(,,WBL); rlabel(,"`(,,WBL)'") - move right_ - dswitch(,,WdBKL); rlabel(,"`(,,WdBKL)'") + D: dswitch(,,); {S: "svg_tt(`dswitch(,,)')" at last [].s+(0,-10bp__)} + thinlines_ + { spline <- from 0.25 along_(D) up 0.1 then up 0.05 left 0.1 + {"svg_tt(`W')" rjust} + spline <- from D.c+(0,m4sc*2) up 0.1 then up 0.05 left 0.1 + {"svg_tt(`B')" rjust }} + thicklines_ + move right_ + D: dswitch(,,WdBK); {"svg_tt(`(,,WdBK)')" at (last [],S)+(0,-4bp__)} + thinlines_ + { spline <- from tr_xy(0,-2) up 0.1 then up 0.10 left 0.1 + {"svg_tt(`dB')" rjust} + spline <- from tr_xy(4,-2) right 0.1 then right 0.05 up 0.15 + {"svg_tt(`K')" above }} + thicklines_ + move right_ + dswitch(,,WBmdDK); {"svg_tt(`(,,WBmdDK)')" at (last [],S)} + move right_ + dswitch(,,WBKTr); {"svg_tt(`(,,WBKTr)')" at (last [],S)} + move right_ + dswitch(,,WdBL); {"svg_tt(`(,,WdBL)')" at (last [],S+(0,-4bp__))} + move right_ + dswitch(,,WBCo); {"svg_tt(`(,,WBCo)')" at (last [],S)} } +# Row 4 move down; right_; { - dswitch(,,WBT); rlabel(,"`(,,WBT)'") + dswitch(,,WBKCo); {S: "svg_tt(`(,,WBKCo)')" at last [].s+(0,-10bp__)} move right_ - dswitch(,,WdBKC); rlabel(,"`(,,WdBKC)'") + dswitch(,,WBCb); {"svg_tt(`(,,WBCb)')" at (last [],S)} move right_ - dswitch(,,WBM); rlabel(,"`(,,WBM)'") + dswitch(,,WBDI); {"svg_tt(`(,,WBDI)')" at (last [],S)} move right_ - dswitch(,,WBCO); rlabel(,"`(,,WBCO)'") + dswitch(,,WBSd); {"svg_tt(`(,,WBSd)')" at (last [],S)} move right_ - dswitch(,,WBMP); rlabel(,"`(,,WBMP)'") + dswitch(,,WBFDI); {"svg_tt(`(,,WBFDI)')" at (last [],S)} move right_ - dswitch(,,WBoKCP); rlabel(,"`(,,WBoKCP)'") + dswitch(,,WBFSd); {"svg_tt(`(,,WBFSd)')" at (last [],S)} } - move down; right_; { - dswitch(,,WBCY); rlabel(,"`(,,WBCY)'") +# Row 5 + move down moveht*5/4; right_; { + dswitch(,,WBTh); {S: "svg_tt(`(,,WBTh)')" at last [].s+(0,-10bp__)} + move right_ + dswitch(,,WBKC); {"svg_tt(`(,,WBKC)')" at (last [],S)} + move right_ + dswitch(,,WBM); {"svg_tt(`(,,WBM)')" at (last [],S)} + move right_ + dswitch(,,WBCO); {"svg_tt(`(,,WBCO)')" at (last [],S)} + move right_ + dswitch(,,WBMP); {"svg_tt(`(,,WBMP)')" at (last [],S)} + move right_ + dswitch(,,WBoKCP); {"svg_tt(`(,,WBoKCP)')" at (last [],S)} + } +# Row 6 + move down moveht*5/4; right_; { + dswitch(,,WBCY); {S: "svg_tt(`(,,WBCY)')" at last [].s+(0,-10bp__)} move right_ - dswitch(,,WBCZ); rlabel(,"`(,,WBCZ)'") + dswitch(,,WBCZ); {"svg_tt(`(,,WBCZ)')" at (last [],S)} move right_ - dswitch(,,WBCE); rlabel(,"`(,,WBCE)'") + dswitch(,,WBCE); {"svg_tt(`(,,WBCE)')" at (last [],S)} move right_ - dswitch(,,WBRH); rlabel(,"`(,,WBRH)'") + dswitch(,,WBRH); {"svg_tt(`(,,WBRH)')" at (last [],S)} move right_ - dswitch(,,WBRdH); rlabel(,"`(,,WBRdH)'") + dswitch(,,WBRdH); {"svg_tt(`(,,WBRdH)')" at (last [],S)} move right_ - dswitch(,,WBRHH); rlabel(,"`(,,WBRHH)'") + dswitch(,,WBRHH); {"svg_tt(`(,,WBRHH)')" at (last [],S)} } +# Row 7 move down; right_; { - dswitch(,,WBMMR); rlabel(,"`(,,WBMMR)'") + dswitch(,,WBMMR); {S: "svg_tt(`(,,WBMMR)')" at last [].s+(0,-10bp__)} move right_ - dswitch(,,WBMM); rlabel(,"`(,,WBMM)'") + dswitch(,,WBMM); {"svg_tt(`(,,WBMM)')" at (last [],S)} move right_ - dswitch(,,WBMR); rlabel(,"`(,,WBMR)'") + dswitch(,,WBMR); {"svg_tt(`(,,WBMR)')" at (last [],S)} move right_ - dswitch(,,WBEL); rlabel(,"`(,,WBEL)'") + dswitch(,,WBEL); {"svg_tt(`(,,WBEL)')" at (last [],S)} move right_ - dswitch(,,WBLE); rlabel(,"`(,,WBLE)'") + dswitch(,,WBLE); {"svg_tt(`(,,WBLE)')" at (last [],S)} move right_ - dswitch(,,WdBKEL); rlabel(,"`(,,WdBKEL)'") + dswitch(,,WBoKEL); {"svg_tt(`(,,WBoKEL)')" at (last [],S)} } - command "</g>" # end font + command "</g>')" # end font .PE diff --git a/graphics/circuit_macros/examples/svg/ex02SVG.m4 b/graphics/circuit_macros/examples/svg/ex02SVG.m4 index 9ec72d8e2a..ad2f7324fb 100644 --- a/graphics/circuit_macros/examples/svg/ex02SVG.m4 +++ b/graphics/circuit_macros/examples/svg/ex02SVG.m4 @@ -1,6 +1,7 @@ .PS # ex02.m4 cct_init +linewid = linewid*4/5 [ [ for angle = 0 to 315 by 45 do { Point_(angle) diff --git a/graphics/circuit_macros/examples/svg/examplesSVG.htmx b/graphics/circuit_macros/examples/svg/examplesSVG.htmx index d4f45ecdef..91bc93f48e 100644 --- a/graphics/circuit_macros/examples/svg/examplesSVG.htmx +++ b/graphics/circuit_macros/examples/svg/examplesSVG.htmx @@ -84,9 +84,10 @@ There are a number of other issues: giving reasonable dimensions in pixels but this has to be insterted into the <embed or <object line. A makefile does it easily but otherwise this could be tedious. - <li> The font face is not specified by default in these diagrams but is - inherited from the enclosing document. The default appearance of labels can - differ according to the browser. + <li> The default font face is not specified in all of these diagrams but is + inherited from the enclosing document, so the appearance of labels can + differ depend on the browser. Some of these diagrams set the font at + the beginning of the diagram source. <li> The <svg tag may require modification from the default used for this test. Dpic might be modified to allow the generation of custom headers but that has not yet been done. @@ -116,8 +117,8 @@ There are a number of other issues: m4tt`'svg_font(font-family="Times")</g><br> m4tt`'svg_font(font-family="Times" font-style="italic")</g><br> m4tt`'svg_font(style="font-family:Times; font-style:italic")</g> - <li>m4tt svg_tspan(</g>text attributes`'m4tt)</g>; - e.g. m4tt`'svg_tspan(font-style="italic" font-size="75%")</g> + <li>m4tt svg_tspan(</g>text attributes, text`'m4tt)</g>; + e.g. m4tt`'svg_tspan(font-style="italic" font-size="75%",XYZ)</g> <li>m4tt svg_it(</g>text`'m4tt)</g>: for italics <li>m4tt svg_tt(</g>text`'m4tt)</g>: for monospace (courier) <li>m4tt svg_norm(</g>text`'m4tt)</g>: for normal text @@ -267,8 +268,11 @@ cfig(AntennasSVG) cfig(AudioSVG) cfig(OpampSVG) cfig(XformSVG) -cfig(RelaySVG) cfig(NPDTSVG) +cfig(ContactSVG) +cfig(ContactsSVG) +cfig(relaycoilSVG) +cfig(RelaySVG) cfig(JackSVG) cfig(ConnSVG) cfig(PconnSVG) @@ -281,7 +285,7 @@ cfig(TgateSVG) cfig(NportSVG) cfig(NLGSVG) cfig(WindingsSVG) -cfig(ex01SVG) +cfig(ex01.m4) cfig(TimerSVG) cfig(OptoisoSVG) cfig(MixerSVG) @@ -294,6 +298,7 @@ cfig(MCSVG) cfig(ex10SVG) cfig(ThreeSVG) cfig(ex17SVG) +cfig(ex02SVG) cfig(ex12SVG) cfig(pwrsupplySVG) cfig(TTLnandSVG) @@ -306,7 +311,6 @@ cfig(DriveSVG) cfig(ex16SVG) cfig(ex03SVG) cfig(MotorControlSVG) -cfig(ex02SVG) cfig(RectifiersSVG) cfig(HeathkitSVG) cfig(lcctSVG) @@ -324,27 +328,27 @@ cfig(CanLogicSVG) cfig(AlogixSVG) cfig(ABlogixSVG) cfig(XORSVG) -cfig(paletteSVG) cfig(ex00SVG) +cfig(controlSVG) cfig(GrayCodeSVG) cfig(CrossbarSVG) cfig(ByteSVG) cfig(RotboxSVG) +cfig(ex06SVG) +cfig(ex09SVG) +cfig(ex05SVG) +cfig(LoglogSVG) cfig(randomSVG) cfig(expSVG) cfig(graysurfSVG) -cfig(CrullerSVG) cfig(shapesSVG) -cfig(ex09SVG) -cfig(ex05SVG) -cfig(controlSVG) -cfig(ex06SVG) -cfig(LoglogSVG) +cfig(AntiqueClockSVG) cfig(cscSVG) cfig(roseSVG) cfig(diamondSVG) cfig(wormSVG) cfig(ButtonsSVG) +cfig(DiniSVG) cfig(SierpinskiSVG) cfig(recycleSVG) cfig(ex15SVG) diff --git a/graphics/circuit_macros/examples/svg/relaycoilSVG.m4 b/graphics/circuit_macros/examples/svg/relaycoilSVG.m4 new file mode 100644 index 0000000000..fc2bc2738f --- /dev/null +++ b/graphics/circuit_macros/examples/svg/relaycoilSVG.m4 @@ -0,0 +1,47 @@ +.PS +# relaycoil.m4 +cct_init + + spc = dimen_/3 +{ relaycoil; S: "svg_tt(`relaycoil')" at last [].s+(0,-20bp__) + { "svg_it(V1)" wid 15bp__ at last [].V1 rjust + "svg_it(V2)" at last [].V2 ljust } + K: relaycoil(NX) with .nw at last [].ne+(spc*4,0); "svg_tt((NX))" \ + at (last [],S) + { thinlines_ + spline <- from K.A1 left 7bp__ then up 4bp__ left 4bp__ + "svg_it(A1)" rjust + arrow <- from K.A2 left 10bp__; "svg_it(A2)" rjust + spline <- from K.A3 left 7bp__ then down 4bp__ left 4bp__ + "svg_it(A3)" rjust + spline <- from K.B1 right 7bp__ then up 4bp__ right 4bp__ + "svg_it(B1)" ljust + arrow <- from K.B2 right 10bp__; "svg_it(B2)" ljust + spline <- from K.B3 right 7bp__ then down 4bp__ right 4bp__ + "svg_it(B3)" ljust + thicklines_ + } + relaycoil(AXSR) with .nw at last [].ne+(spc*5,0); "svg_tt((AXSR))" \ + at (last [],S) + { "svg_it(V1)" at last [].V1 rjust; "svg_it(V2)" at last [].V2 rjust } + relaycoil(BXSR) with .nw at last [].ne+(spc*2,0); "svg_tt((BXSR))" \ + at (last [],S) + { "svg_it(V1)" at last [].V1 ljust; "svg_it(V2)" at last [].V2 ljust } + relaycoil(SR) with .nw at last [].ne+(spc*4,0); "svg_tt((SR))" at (last [],S) + relaycoil(SO) with .nw at last [].ne+(spc,0); "svg_tt((SO))" at (last [],S) + relaycoil(SOR) with .nw at last [].ne+(spc,0); "svg_tt((SOR))" at (last [],S) + } +{ + move down_ 3/4; right_ + relaycoil(HS); S: "svg_tt((HS))" at last [].s+(0,-12bp__) + relaycoil(NAC) with .nw at last [].ne+(spc,0); "svg_tt((NAC))" at (last [],S) + relaycoil(AC) with .nw at last [].ne+(spc,0); "svg_tt((AC))" at (last [],S) + relaycoil(ML) with .nw at last [].ne+(spc,0); "svg_tt((ML))" at (last [],S) + relaycoil(PO) with .nw at last [].ne+(spc,0); "svg_tt((PO))" at (last [],S) + relaycoil(RM) with .nw at last [].ne+(spc,0); "svg_tt((RM))" at (last [],S) + relaycoil(RH) with .nw at last [].ne+(spc,0); "svg_tt((RH))" at (last [],S) + relaycoil(TH) with .nw at last [].ne+(spc,0); "svg_tt((TH))" at (last [],S) + relaycoil(EL) with .nw at last [].ne+(spc,0); "svg_tt((EL))" at (last [],S) + } + +.PE diff --git a/graphics/circuit_macros/examples/svg/tstSVG.htmx b/graphics/circuit_macros/examples/svg/tstSVG.htmx index 1dd990c82a..f15d09b7c7 100644 --- a/graphics/circuit_macros/examples/svg/tstSVG.htmx +++ b/graphics/circuit_macros/examples/svg/tstSVG.htmx @@ -70,8 +70,8 @@ more basic. m4tt`'svg_font(font-family="Times")</g><br> m4tt`'svg_font(font-family="Times" font-style="italic")</g><br> m4tt`'svg_font(style="font-family:Times; font-style:italic")</g> - <li>m4tt svg_tspan(</g>text attributes`'m4tt)</g>; - e.g. m4tt`'svg_tspan(font-style="italic" font-size="75%")</g> + <li>m4tt svg_tspan(</g>text attributes, text`'m4tt)</g>; + e.g. m4tt`'svg_tspan(font-style="italic" font-size="75%",XYZ)</g> <li>m4tt svg_it(</g>text`'m4tt)</g>: for italics <li>m4tt svg_tt(</g>text`'m4tt)</g>: for monospace (courier) <li>m4tt svg_norm(</g>text`'m4tt)</g>: for normal text diff --git a/graphics/circuit_macros/examples/svg/xx.html b/graphics/circuit_macros/examples/svg/xx.html deleted file mode 100644 index 6b4881d450..0000000000 --- a/graphics/circuit_macros/examples/svg/xx.html +++ /dev/null @@ -1,11 +0,0 @@ -<svg xmlns="http://www.w3.org/2000/svg" version="1.1"> -<g> - <text x = "10" y = "25" font-size = "20"> - <tspan x = "10" y = "60"> - T<tspan dy="10">i+2</tspan> - <tspan dy="-10">= T</tspan><tspan dy="10">i</tspan> - <tspan dy="-10">+ T</tspan><tspan dy="10">i+1</tspan> - </tspan> - </text> - </g> -</svg> |