
A pentagram is a star polygon, consisting of a central pentagon of which each side forms the base of an isosceles triangle. The vertex of each triangle, a point of the star, is 36 degrees.




Task

Draw (or print) a regular pentagram, in any orientation. Use a different color (or token) for stroke and fill, and background. For the fill it should be assumed that all points inside the triangles and the pentagon are inside the pentagram.




See also
 Angle sum of a pentagram


const DIM=200, SIDES=5, A=360/SIDES, R=DIM.toFloat();
vs:=[0.0..360-A,A].apply("toRad");  // angles of vertices
#<<<
0'|<?xml version="1.0" standalone="no" ?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/PR-SVG-20010719/DTD/svg10.dtd">
<svg height="%d" width="%d" style="" xmlns="http://www.w3.org/2000/svg">
<rect height="100%" width="100%" style="fill:bisque;" />|
#<<<
.fmt(DIM*2, DIM*2).println();
 
var vertices=vs.pump(List,fcn(a){ R.toRectangular(a) }); //( (x,y), (x,y)...
SIDES.pump(String,pline).println();  // the line pairs that draw the pentagram
 
fcn pline(n){ a:=(n + 2)%SIDES; // (n,a) are the endpoints of the right leg
   pts:=String("\"", ("% 0.3f,% 0.3f "*2), "\" "); // two points
   vs:='wrap(){ T(n,a).pump(List,vertices.get).flatten() }; //(x,y, x,y)
   String(
     (0'|<polyline points=| + pts).fmt(vs().xplode()),
      0'|style="fill:seashell; stroke:blue; stroke-width:3;" |,
      0'|transform="translate(%d,%d) rotate(-18)"|.fmt(DIM,DIM),
      " />\n"
   );
}
println("</svg>");