Debian Codegraph @

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

raw
1 .PS
2 # Egg.m4
3 # https://tex.stackexchange.com/questions/74168/how-can-i-draw-an-egg-using-tikz
4 threeD_init
5 NeedDpicTools
6
7 define Eggshape { (0.78*cos(($2)/4)*sin($2),-cos($2))*($1) } # -pi < arg2 < pi
8
9 size = 2
10 npts = 41
11
12 HL: Eggshape(size*0.4,-pi_*3/4) # Highlight
13 P: Eggshape(size,pi_/4)
14 d = zabs(P)
15 nlines = int(d/lthick*1.5)
16 # This way of blending colors is not the
17 # simplest for a single postprocessor but it
18 # works for multiple postprocessors, e.g. SVG
19 define(`Orange',`1, 0.5, 0')
20 define(`Gray', `0.5, 0.5, 0.5')
21 define(`White', `1, 1, 1')
22
23 define(`eggblend',
24 `sum3D(sprod3D($1,Orange),
25 sum3D(sprod3D($2,White),
26 sprod3D($3,Gray)))')
27
28 define(`normalize',`($1)/($1+$2+$3), ($2)/($1+$2+$3), ($3)/($1+$2+$3)')
29
30 define EggLine {
31 for i=0 to npts do {
32 P[i]: HL*(1-($1))+Eggshape(size*($1),i/npts*twopi_-pi_) }
33 fitcurve(P,npts,outlined rgbstring($2,$3,$4))
34 }
35
36 ShadeObject(EggLine, nlines,
37 0, eggblend(normalize(0.3, 1, 0)),
38 0.2, eggblend(normalize(0.5, 0.5, 0)),
39 0.5, eggblend(normalize(0.5, 0.4, 0.2)),
40 1, eggblend(normalize(0.5, 0, 0.7))
41 )
42
43 .PE