Debian Codegraph @

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

raw
1 .PS
2 # Stator.m4
3 # https://tex.stackexchange.com/questions/612620/how-to-paint-inside-a-set-of-lines
4 gen_init
5 scale = 0.5
6
7 outerwid = 5/2
8 innerwid = 3.7/2
9 nteeth = 32
10 toothdepth = (innerwid/2)*(twopi_/nteeth)
11 statordepth = toothdepth*4
12 viewangle = 30
13 outershade = 0.9
14 topshade = 0.8
15 innershade = 0.6
16 toothshade = 0.5
17
18 cv = cosd(viewangle)
19 sv = sind(viewangle)
20 define ang { ($1)/nteeth*twopi_ }
21
22 T: (0,statordepth*cv)
23 Tc: (0,toothdepth*cv)
24 for i = 0 to nteeth/2 do { for j=1 to -1 by -2 do { # Shaded tooth walls
25 P: (cos(ang(i)+pi_/2)*j,sin(ang(i)+pi_/2)*sv)*outerwid/2
26 Q: P*innerwid/outerwid
27 line from P to P+Tc then to Q+Tc then to Q then to P \
28 shaded rgbstring(toothshade,toothshade,toothshade) } }
29 shade(innershade, # inner arc and teeth
30 E: ellipsearc(innerwid,innerwid*sv,pi_,0,0,cw) with .C at T
31 move to (innerwid/2,0)
32 toothht = toothdepth*cv
33 for i = 0 to nteeth/2 do {
34 line up toothht
35 ellipsearc(innerwid,innerwid*sv,ang(i),ang(i+1),0,ccw) with .Start at Here
36 move to last [].End
37 toothht = -toothht } )
38 shade(outershade, # outer arc and teeth
39 E: ellipsearc(outerwid,outerwid*sv,0,pi_,0,cw) with .C at T
40 line down statordepth*cv from E.End
41 toothht = toothdepth*cv
42 for i = nteeth/2 to nteeth-1 do {
43 line up toothht
44 ellipsearc(outerwid,outerwid*sv,ang(i),ang(i+1),0,ccw) with .Start at Here
45 move to last [].End
46 toothht = -toothht }
47 line up statordepth*cv from E.Start-T )
48 for r=innerwid to outerwid by lthick*2 do { # shade the top
49 ellipse wid r ht r*sv with .c at T \
50 outlined rgbstring(topshade,topshade,topshade) }
51 ellipse wid outerwid ht outerwid*sv with .c at T
52 ellipse wid innerwid ht innerwid*sv with .c at T
53
54 .PE