| 1 |
.PS |
| 2 |
# Star.m4 |
| 3 |
# https://tex.stackexchange.com/questions/605132/how-can-i-insert-a-nine-pointed-star-in-a-latex-document |
| 4 |
gen_init |
| 5 |
|
| 6 |
# star(keys) |
| 7 |
# keys: size=expr; |
| 8 |
# points=expr; |
| 9 |
# angle=expr; last convex vertex ang |
| 10 |
# depth=expr; inner vertex fraction |
| 11 |
# line=attributes; |
| 12 |
define(`star',`[ pushkeys_(`$1', |
| 13 |
`size:linewid; points:5; angle:90; depth:1/(m4points-1); line::N') |
| 14 |
dang = 360/m4points |
| 15 |
T: (Rect_(m4size/2*m4depth,m4angle+dang/2)) # concave inner vertex |
| 16 |
S: 1/2 between T and (Rect_(m4size/2,m4angle)) |
| 17 |
U: (Rect_(m4size/2,m4angle+dang)) # convex outer vertex |
| 18 |
line m4line from S to T then to U |
| 19 |
for i=1 to m4points-1 do { |
| 20 |
T: (Rect_(m4size/2*m4depth,m4angle+i*dang+dang/2)) |
| 21 |
U: (Rect_(m4size/2,m4angle+(i+1)*dang)) |
| 22 |
continue to T then to U } |
| 23 |
continue to S; popdef(`size',`points',`angle',`depth',`m4line')]') |
| 24 |
|
| 25 |
linewid = linewid*2 |
| 26 |
ifelse(1,1,` |
| 27 |
star |
| 28 |
star(size=1) |
| 29 |
star(points=4) |
| 30 |
star(depth=1/4) |
| 31 |
star(line=outlined "red") |
| 32 |
star(points=8) |
| 33 |
star(points=9;line=outlined "red" shaded "magenta") |
| 34 |
') |
| 35 |
#for_(3,8,1,` |
| 36 |
#star(points=m4x;line=outlined "red" shaded "magenta")') |
| 37 |
|
| 38 |
.PE |