A star pattern in SVG
<svg height="800" width="800" xmlns="http://www.w3.org/2000/svg"> <defs> <g transform="scale(0.33,0.33)" id='star'> <polygon points='22.45 -30.9 95.11 -30.9 36.33 11.8 58.78 80.9 0 38.2 -58.78 80.9 -36.33 11.8 -95.11 -30.9 -22.45 -30.9 0 -100'/> </g> <g id='rwb'> <g transform='translate(0 -300)'> <use href='#star' fill='red'/> </g> <g transform='rotate(15) translate(0 -300)'> <use href='#star' fill='blue'/> </g> <g transform='rotate(30) translate(0 -300)'> <use href='#star' fill='none' stroke='black' stroke-width='2.5'/> </g> </g> <g id='quarter'><use href='#rwb'/> <g transform='rotate(45)'><use href='#rwb'/></g> </g> <g id='half'><use href='#quarter'/> <g transform='rotate(90)'><use href='#quarter'/></g> </g> <g id='circle'><use href='#half'/> <g transform='rotate(180)'><use href='#half'/></g> </g> </defs> <g transform='translate(400 400)'> <use href='#circle'/> <g transform='rotate(5) scale(0.75)'> <use href='#circle'/> </g> <g transform='rotate(10) scale(0.56)'> <use href='#circle'/> </g> <g transform='rotate(15) scale(0.42)'> <use href='#circle'/> </g> <g transform='rotate(15) scale(0.316)'> <use href='#circle'/> </g> </g> </svg>
#!/home/ben/software/install/bin/perl use Z; use Math::Trig; my $twof = 4*pi/5; my $s144 = sin ($twof); my $c144 = cos ($twof); my $t144 = $s144 / ($c144 - 1); my $x = (cos (2*pi/5) - 1) * $t144; my $y = 1 + $x / $t144; my $exy = cos (deg2rad (72)); my $factor = sqrt ($x**2 + $y**2); my $radius = 100; my $max = 10; my @points; for my $s (1..$max) { my $a = 2*pi*$s/$max; my $r = $radius; if (($s % 2) == 1) { $r *= $factor; } my $x = sin ($a) * $r; my $y = -cos ($a) * $r; push @points, [$x, $y]; } print <<EOF; <svg height="800" width="800" xmlns="http://www.w3.org/2000/svg"> EOF print "<polygon points='"; for my $point (@points) { printf ("%.2f %.2f\n", $point->[0], $point->[1]); } print "'/>\n"; print <<EOF; </svg> EOF
Copyright © Ben Bullock 2009-2024. All
rights reserved.
For comments, questions, and corrections, please email
Ben Bullock
(benkasminbullock@gmail.com).
/
Privacy /
Disclaimer