#! /usr/local/bin/perl -w

use strict;

for ( my $n=3 ; $n<14 ; $n++ ) {
    for ( my $i=1 ; 2*$i<=$n ; $i++ ) {
	open F, ">", "star.ps";
	print F <<__EOF__;
%! /usr/local/bin/gv
40 dup translate 1 setlinecap 1 setlinejoin 2 setlinewidth
/spoint { 360 mul $n div dup sin neg 36 mul exch cos 36 mul } bind def
/k 0 def {
    k spoint moveto k $i add spoint lineto stroke
    k 1 add dup /k exch def
    $n ge { exit } if
} loop
showpage quit
__EOF__
	close F;
	system "gs -dNOPAUSE -sDEVICE=ppmraw -r1440x1440 -g1600x1600 -sOutputFile=star.ppm star.ps";
	system "convert star.ppm -scale 400x400 star.png";
	my $zn = sprintf "%02d", $n;
	my $zi = sprintf "%01d", $i;
	system "mv -f star.png star-$zn-$zi.png";
	system "rm -f star.ps star.ppm";
    }
}
