summaryrefslogtreecommitdiff
path: root/graphics/circuit_macros/examples/svg/cscSVG.m4
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/circuit_macros/examples/svg/cscSVG.m4')
-rw-r--r--graphics/circuit_macros/examples/svg/cscSVG.m4101
1 files changed, 54 insertions, 47 deletions
diff --git a/graphics/circuit_macros/examples/svg/cscSVG.m4 b/graphics/circuit_macros/examples/svg/cscSVG.m4
index 8f1b954669..05cf0c70d4 100644
--- a/graphics/circuit_macros/examples/svg/cscSVG.m4
+++ b/graphics/circuit_macros/examples/svg/cscSVG.m4
@@ -1,19 +1,21 @@
.PS
#.PS 3.5
# csc.m4
+# This file includes AntiqueClock and works for PSTricks, Tikz, and SVG
gen_init
+NeedDpicTools
-skale = 3.5/3.97*0.9955
+skale = 0.878
circlerad=1.91*skale
hubrad=0.10*skale
s=0.5*skale
-define(`midnight',`26,26,112')
-define(`white',`255,255,255')
-define(`spokethick',0.1)
+define(`midnight',`0.1, 0.1, 0.44')
+define(`white',`1, 1, 1')
+define(`spokewidth',0.1)
define(`spoke',`dnl
- {line from rvec_(0,hubrad-spokethick/2) to rvec_(circlerad-0.05,0)}
- {line from rvec_(0,-(hubrad-spokethick/2)) to rvec_(circlerad-0.05,0)}')
+ {line from rvec_(0,hubrad-spokewidth/2) to rvec_(circlerad-0.05,0)}
+ {line from rvec_(0,-(hubrad-spokewidth/2)) to rvec_(circlerad-0.05,0)}')
define(`lwid',1)
define(`coord',`(s*(`$1'),s*(`$2'))')
@@ -23,7 +25,7 @@ rgbdraw(midnight,
linethick=`0.'eval(lwid*15)/(1pt__)
{circle with .c at Here
circle invis diam last circle.diam + linethick pt__ at last circle }
- linethick=spokethick/(1pt__)
+ linethick=spokewidth/(1pt__)
for angle = 0 to 330 by 30 do {
Point_(angle)
{spoke}
@@ -46,7 +48,7 @@ rgbdraw(midnight,
# Sail
thinlines_
- setrgb(midnight)
+ rgbfill(midnight,
line from coord(0.44,3.38) to coord(0.44,2.6) \
then to coord(2.1,-1.75) \
then to coord(1.22,-1.53) \
@@ -60,34 +62,33 @@ rgbdraw(midnight,
then to coord(-0.92,1.73) \
then to coord(0,2.9) \
then to coord(0.44,3.38)
+ )
# Hull
+ rgbfill(midnight,
spline from coord(2.1,-1.75) to coord(1.9,-2.2) \
then to coord(1.85,-2.3) then to coord(1.8,-2.33) \
then to coord(1,-2.5) then to coord(0,-2.6) then to coord(-0.38,-2.57) \
then to coord(-2.13,-2.4)
line to coord(-2.2,-2.05) then to coord(2.1,-1.75)
-# spline to coord(-1,-2.08) then to coord(0.55,-1.77)
- line to coord(2.1,-1.75)
- resetrgb
- setrgb(white)
- spline from coord(-2.2,-2.05) to coord(-1,-2.08) then to coord(0.55,-1.77)
- line to coord(-2.2,-2.05)
- resetrgb
- linethick=`0.'eval(lwid*15)/(1pt__)
-
+ spline to coord(-1,-2.08) then to coord(0.55,-1.77)
+ )
]
+
Clock: [
+# PSTricks, tikz, or svg only:
+ifelse(ifpstricks(T)`'ifpgf(T)`'ifsvg(T),T,`
#.PS
-# AntiqueClockSVG.m4
+# AntiqueClock.m4
#gen_init
-svg_font(font-family="sans-serif" font-stretch="condensed")
+#NeedDpicTools
-# https://tex.stackexchange.com/questions/236923/generate-analog-clock-with-numbered-face-add-seconds-roman-numerals
+iflatex(`latexcommand({\sf)')
+ifsvg(svg_font(font-family="sans-serif" font-stretch="condensed")
+# svg_rot_init(test))
+ svg_rot_init(cscSVG))
-#svg_rot_init(AntiqueClockSVG)
-#svg_rot_init(test)
-svg_rot_init(cscSVG)
+# https://tex.stackexchange.com/questions/236923/generate-analog-clock-with-numbered-face-add-seconds-roman-numerals
# `hms2deg(hr,min,sec) hr:min:sec to degrees
# blank arg1: degrees for minute hand
@@ -148,6 +149,7 @@ define(`AntiqueHourHand',`[ hhsf = (`$1')/2.2
fitcurve(X,n,shaded rgbstring(0,0,0))
]')
+
define(`AntiqueClock',`[ # h,m,s,diam
# Clock size parameters:
hour = ifelse(`$1',,3,`$1')
@@ -155,8 +157,8 @@ define(`AntiqueClock',`[ # h,m,s,diam
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
+ 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
@@ -191,32 +193,35 @@ Face: circle thick 0 fill_(1) rad r3 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) }
+ ifsvg(`define adj {+(-cosd($`'1)*textht*0.5*sign(180-($`'1)),\
+ (0.25+0.25*cosd(2*($`'1)))*textht) }',
+ `define adj {}')
+ define adj {}
+
# 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))
- }
+ iflatex(`command sprintf("\font\outerfont=cmss12 at %4.2fin",r3-r4)')
+ ifsvg(`textht = (r3-r4)*0.6')
+ for_(-15,15,5,`aa=90-(m4x)*6
+ r_text(eval(-(m4x)*6),eval((m4x+60)%60),
+ at C+(Rect_((r3+r4)/2,aa)) adj(aa))')
+ for_(20,40,5,`aa=450-(m4x)*6
+ r_text(eval(180-m4x*6),m4x,at C+(Rect_((r3+r4)/2,aa)) adj(aa))')
# 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(tt-90, "mx" at C+R+adj(tt)) ',
+ iflatex(`command sprintf("\font\innerfont=cmss12 at %4.2fin",r5-r6)')
+ ifsvg(`textht = (r5-r6)*0.6')
+ Loopover_(`mx',`aa=180-(m4Lx-1)*30
+ r_text(eval(120-m4Lx*30),iflatex({\innerfont mx},mx),
+ at C+(Rect_((r5+r6)/2,aa)) adj(aa))',
IX,X,XI,XII,I,II,III)
- Loopover_(`mx',`tt = 360-m4Lx*30
- R: (Rect_((r5+r6)/2,tt))
- svg_rot(tt-270, "mx" at C+R+adj(tt)) ',
+ Loopover_(`mx',`aa=360-m4Lx*30
+ r_text(eval(90-m4Lx*30), iflatex({\innerfont mx},mx),
+ at C+(Rect_((r5+r6)/2,aa)) adj(aa))',
IV,V,VI,VII,VIII)
# Inner tics
@@ -230,13 +235,15 @@ Face: circle thick 0 fill_(1) rad r3 at C
# Center
dot(at C,0.1/4*r1,1)
- ]')
+ ]') `# AntiqueClock'
Clock1: AntiqueClock(,,,3.5)
-# Clock2: AntiqueClock(4,48,07,2) at Clock1.e+(1.5,0)
+# Clock2: AntiqueClock(4,50,07,2) at Clock1.e+(1.5,0)
+
+ iflatex(`latexcommand(}%)')
+ ifsvg(`command "</g>"')
- command "</g>" # end font
#.PE
+',` "AntiqueClock.m4 requires PSTricks, Tikz-pgf, or SVG" ')
] with .sw at last [].se+(0.25,0)
-
.PE