summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Egg.m4
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-03-11 21:11:43 +0000
committerKarl Berry <karl@freefriends.org>2023-03-11 21:11:43 +0000
commit6bc45f3087df0ce19bdf3c57a0aec55944ec40ed (patch)
tree3faac3b12b92fc4ba09b62c0472a9b3654dada6a /Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Egg.m4
parent86d58778de06c53c2e0b20f25556b96619a2dc42 (diff)
circuit-macros (11mar23)%
git-svn-id: svn://tug.org/texlive/trunk@66549 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Egg.m4')
-rw-r--r--Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Egg.m442
1 files changed, 42 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Egg.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Egg.m4
new file mode 100644
index 00000000000..3cab249877e
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Egg.m4
@@ -0,0 +1,42 @@
+.PS
+# Egg.m4
+# https://tex.stackexchange.com/questions/74168/how-can-i-draw-an-egg-using-tikz
+threeD_init
+NeedDpicTools
+
+define Eggshape { (0.78*cos(($2)/4)*sin($2),-cos($2))*($1) } # -pi < arg2 < pi
+
+ size = 2
+ npts = 41
+
+ HL: Eggshape(size*0.4,-pi_*3/4) # Highlight
+ P: Eggshape(size,pi_/4)
+ d = zabs(P)
+ nlines = int(d/lthick*1.5)
+ # This way of blending colors is not the
+ # simplest for a single postprocessor but it
+ # works for multiple postprocessors, e.g. SVG
+define(`Orange',`1, 0.5, 0')
+define(`Gray', `0.5, 0.5, 0.5')
+define(`White', `1, 1, 1')
+define(`eggblend',
+ `sum3D(sprod3D($1,Orange),
+ sum3D(sprod3D($2,White),
+ sprod3D($3,Gray)))')
+
+define(`normalize',`($1)/($1+$2+$3), ($2)/($1+$2+$3), ($3)/($1+$2+$3)')
+
+define EggLine {
+ for i=0 to npts do {
+ P[i]: HL*(1-($1))+Eggshape(size*($1),i/npts*twopi_-pi_) }
+ fitcurve(P,npts,outlined rgbstring($2,$3,$4))
+ }
+
+ ShadeObject(EggLine, nlines,
+ 0, eggblend(normalize(0.3, 1, 0)),
+ 0.2, eggblend(normalize(0.5, 0.5, 0)),
+ 0.5, eggblend(normalize(0.5, 0.4, 0.2)),
+ 1, eggblend(normalize(0.5, 0, 0.7))
+ )
+
+.PE