| 1 |
.PS |
| 2 |
# diamondDPV.m4 |
| 3 |
gen_init |
| 4 |
NeedDpicTools |
| 5 |
# See LaTeX Graphics Companion pp 57-58 and |
| 6 |
# https://tex.stackexchange.com/questions/730392/rotating-triangle |
| 7 |
ifdpic(` |
| 8 |
dimen = 1.3 |
| 9 |
ratio = 0.9 |
| 10 |
n = 30 |
| 11 |
|
| 12 |
North: (0,dimen) |
| 13 |
East: (dimen,0) |
| 14 |
South: (0,-dimen) |
| 15 |
West: (-dimen,0) |
| 16 |
|
| 17 |
define(`diamond',`[ |
| 18 |
for i = 2 to n do { |
| 19 |
ifelse(`$1',, |
| 20 |
`hsvtorgb(hue,1,1,r0,g0,b0) |
| 21 |
line from North to East then to South then to West then to North \ |
| 22 |
shaded rgbstring(r0,g0,b0) |
| 23 |
hue = hue+360/(n-1)', |
| 24 |
`shade(`$1', |
| 25 |
line from North to East then to South then to West then to North)') |
| 26 |
Tmp: North |
| 27 |
North: ratio between East and North |
| 28 |
East: ratio between South and East |
| 29 |
South: ratio between West and South |
| 30 |
West: ratio between Tmp and West |
| 31 |
}]') |
| 32 |
|
| 33 |
define(`triangle',`[ |
| 34 |
for i = 2 to n do { |
| 35 |
hue = 180+(i-2)/(n-1)*360 |
| 36 |
hsvtorgb(hue,1,1,r0,g0,b0) |
| 37 |
line from North to East then to West then to North shaded rgbstring(r0,g0,b0) |
| 38 |
Tmp: North |
| 39 |
North: ratio between East and North |
| 40 |
East: ratio between West and East |
| 41 |
West: ratio between Tmp and West |
| 42 |
}]') |
| 43 |
|
| 44 |
linethick = 0.4 |
| 45 |
diamond( (n-i)/(n-2) ) |
| 46 |
hue = 0 |
| 47 |
diamond with .w at last [].e+(0.125,0) |
| 48 |
North: (0,dimen*sqrt(3)/2) |
| 49 |
East: (dimen,-dimen*sqrt(3)/2) |
| 50 |
West: (-dimen,-dimen*sqrt(3)/2) |
| 51 |
hue = 180 |
| 52 |
triangle with .w at last [].e |
| 53 |
', |
| 54 |
`box "diamond.m4" "requires" "dpic"') |
| 55 |
|
| 56 |
.PE |