%!PS-Adobe-2.0 %%Pages: 0 1 %%BoundingBox: 0 0 612 792 %%EndComments /n 14 def % number of points on star % use n = 14, 16, with changes in "points" function below % n = 10, 18 require additional changes, not shown /h 0.1 def % distance between 6 loops and centerline /whitestroke 0.085 def % width of wide while lines % use of white, then color creates white "gaps" along the way, width (0.1 - 0.08)/2 /colorstroke1 0.075 def % not used in this version /colorstroke2 0.035 def % not used in this version /outercolor{ green } def % not used in this version, colors are constructed /innercolor{ red } def % not used in this version, colors are constructed /th 360 n div def % angles in one segment of disk % a few colors to use /White {0 0 0 0 setcmykcolor}def /white {0 0 0 0 }def /Black {1 1 1 0 setcmykcolor}def /black {1 1 1 0 }def /Red {0 1 1 0 setcmykcolor}def /red {0 1 1 0 }def /Cyan {1 0 0 0 setcmykcolor}def /cyan {1 0 0 0 }def /Green {1 0 1 0 setcmykcolor}def /green {1 0 1 0}def /Blue {1 1 0 0 setcmykcolor}def /blue {1 1 0 0 }def /ltblue {.5 .5 0 0 }def /Yellow {0 0 1 0 setcmykcolor}def /yellow {0 0 1 0}def /Cyan {1 0 0 0 setcmykcolor}def /backcolor {Black} def /inch {72 mul} def /back { % fill in background color newpath 0 0 moveto 8.5 inch 0 lineto 8.5 inch 11.7 inch lineto -8.5 inch 11.7 inch lineto closepath backcolor fill } def % back % intersection point of two lines /inter { % stack x1f y1f x2f y2f u1f v1f u2f v2f, two intersecting lines /v2f exch def /u2f exch def /v1f exch def /u1f exch def /y2f exch def /x2f exch def /y1f exch def /x1f exch def x1f x2f sub abs 0.000001 lt { /nf v2f v1f sub u2f u1f sub div def x1f % return xInter nf x1f mul v1f add nf u1f mul sub % return yInter } { u1f u2f sub abs 0.000001 lt { /mf y2f y1f sub x2f x1f sub div def u1f % return xInter mf u1f mul y1f add mf x1f mul sub % return yInter } { /mf y2f y1f sub x2f x1f sub div def /nf v2f v1f sub u2f u1f sub div def v1f nf u1f mul sub y1f sub mf x1f mul add mf nf sub div %return xInter mf v1f mul mf nf mul u1f mul sub nf y1f mul sub mf nf mul x1f mul add mf nf sub div % return yInter } ifelse } ifelse } def % inter % point a ratio r of the way from one point to another /short { % stack: xf yf uf vf rf % (x,y) is 1st point, (u,v) is 2nd % returned on stack is (w,z), pt on line % r of the way from 1st to 2nd /rf exch def /vf exch def /uf exch def /yf exch def /xf exch def /wf xf rf uf xf sub mul add def wf % return x coord of pt on stack /zf yf rf vf yf sub mul add def zf % return y coord of pt on stack } def % short % points needed for drawing a 6th pie shape (if n = 12) /points { /c0x 1 def % ci counterclockwise aroung circle, i >= 0 /c0y 0 def /c1x th cos def /c1y th sin def /c2x th 2 mul cos def /c2y th 2 mul sin def /c3x th 3 mul cos def /c3y th 3 mul sin def /c4x th 4 mul cos def /c4y th 4 mul sin def /c5x th 5 mul cos def /c5y th 5 mul sin def /cm1x th neg cos def % cmi counterclockwise around circle, i < 0 /cm1y th neg sin def /cm2x th 2 mul neg cos def /cm2y th 2 mul neg sin def /cm3x th 3 mul neg cos def /cm3y th 3 mul neg sin def % from here on, must draw picture carefully % d1 is inter (c1 - c5, 0 - c2) c1x c1y c5x c5y 0 0 c2x c2y inter /d1y exch def /d1x exch def % d2 is inter (c1 - cm3, 0 - c0) c1x c1y cm3x cm3y 0 0 c0x c0y inter /d2y exch def /d2x exch def /f0x c2x def /f0y 0 def % d3 is inter (c2 - f0, (0,h) - (1,h)) c2x c2y f0x f0y 0 h 1 h inter /d3y exch def /d3x exch def % d4 is inter (0 - c2, (0,h) - (1,h)) 0 0 c2x c2y 0 h 1 h inter /d4y exch def /d4x exch def /d5x h th 2 mul sin div def % point closest to origin /d5y 0 def /f1x c2x def /f1y c2y h 90 th 2 mul sub sin div sub def % d6 is inter (d5 - f1, c0 - c4), vertex of small quadrilateral d5x d5y f1x f1y c0x c0y c4x c4y inter /d6y exch def /d6x exch def /d7x d6x def % 4th vertex of quadrilateral /d7y d6y neg def % new points related to fancier approach d3x d3y c2x c2y 0.9 short % 0.88 for n=12, 0.9 for n=14,16 /e1y exch def /e1x exch def c1x c1y d1x d1y 0.9 short /e3y exch def /e3x exch def d3x d3y d4x d4y 0.925 short /e2y exch def /e2x exch def cm1x cm1y d2x d2y 0.9 short /g3y exch def /g3x exch def d7x d7y c0x c0y 0.9 short % 0.88 for n=12, 0.9 for n=14,16 /g1y exch def /g1x exch def d7x d7y d5x d5y 0.925 short /g2y exch def /g2x exch def c2x c2y d3x d3y 0.55 short % 0.6 for n=12, 0.55 for n=14, 0.5 for n=16 /h1y exch def /h1x exch def d5x d5y d6x d6y 0.5 short /h2y exch def /h2x exch def } def % points back % fill in background color points % define points needed % need 5 paths because of order of crossings % separate paths are attached exactly, but the picture % ends up with tiny wide lines at the connection points % of width "zero". They are visible, but get no bigger under magnification /path1 { newpath e1x e1y moveto h1x h1y lineto } def % path1 /path2 { % includes the entire outer star newpath e3x e3y moveto c1x c1y lineto d2x d2y lineto g3x g3y lineto } def % path2 /path3 { newpath g1x g1y moveto c0x c0y lineto d6x d6y lineto h2x h2y lineto } def % path3 /path4 { newpath h1x h1y moveto d3x d3y lineto e2x e2y lineto } def % path4 /path5 { newpath h2x h2y moveto d5x d5y lineto g2x g2y lineto } def % path5 /drawseg { % draw one of the paths gsave backcolor whitestroke setlinewidth stroke % stroke wide white line grestore % get a shading effect by changing strokewidth and color /strokex 0.075 def /y 0.75 def /x 1 def 1 1 75 { % this for loop is a lot of execution, 75 loops gsave y x x 0 setcmykcolor % start with 0.75 1 1 0, or dark red strokex setlinewidth stroke /y y 0.01 sub def % gradually make more red /x x 0.99 mul def % gradually change the other two color fields /strokex strokex 0.001 sub def % gradually shorten strokewidth grestore } for } def % drawseg /drawsector { % draw all 5 paths, for one sector path1 drawseg path2 drawseg path3 drawseg path4 drawseg path5 drawseg } def % drawsector /drawstar { % draw entire star % loop through each sector of disk % iterate n/2 times 1 1 n 2 div { drawsector 360 2 mul n div rotate } for } def % drawstar 200 200 scale % original circle radius = 1 1.5 1.5 translate % otherwise, centered at origin drawstar showpage