Debian Codegraph @

texmf-dist/doc/latex/circuit-macros/examples/dpv/SierpinskiDPV.m4

raw
1 .PS
2 # Sierpinski.m4
3 gen_init
4 [
5 define Sierpinski {
6 if $1 > 0.04 then {
7 d = $1/2-lh
8 shade(1,line from $2+(d/2,d/2*s3+lw*2) right d/2 up d/2*s3 then left d*2 \
9 then right d down d*s3 then right d/2 up d/2*s3 )
10 Sierpinski($1/2,$2-($1/2,0))
11 Sierpinski($1/2,$2+($1/2,0))
12 Sierpinski($1/2,$2+(0,$1*s3/2))
13 }
14 }
15
16 r = 3
17 linethick = 0.2
18 #linethick = 1/2 /(1pt__)
19 lw = linethick pt__ /2
20 s3 = sqrt(3)
21 lh = lw*s3
22 A: 3,3
23 d = r/2-lh
24 shade(0,line from A+(0,lw) right d then up d*s3 left d then down d*s3 left d\
25 then right d )
26 ifpstricks(`psset_(linecolor=white)')
27 Sierpinski(r/2,A)
28
29 ifpstricks(`psset_(linecolor=black)')
30 thicklines_
31 ]
32
33 # CayleyGraph.m4
34 [
35 define CayleyGraph {
36 if $3 > 0 then {
37 { line to Here+(cosd($2),sind($2))*($1)
38 exec sprintf("CayleyGraph(%g,%g,%g);", ($1)/2, $2, $3-1); }
39 { line to Here+(cosd($2+90),sind($2+90))*($1)
40 exec sprintf("CayleyGraph(%g,%g,%g);", ($1)/2, $2+90, $3-1); }
41 { line to Here+(cosd($2-90),sind($2-90))*($1)
42 exec sprintf("CayleyGraph(%g,%g,%g);", ($1)/2, $2-90, $3-1); }
43 }
44 }
45
46 size = 2
47 depth = 6
48 for t=0 to 270 by 90 do {
49 line from (0,0) to (cosd(t),sind(t))*size/2;
50 { exec sprintf("CayleyGraph(%g,%g,%g);",size/4,t,depth); }
51 }
52 ] scaled 3/4 with .sw at last [].se+(-0.25,0)
53
54 .PE