🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #1359

Npoly for your toolchest

#1359
From: John Hascall
Date: Wed, 22 Nov 1989 22:59
67 lines
1781 bytes
   Here's another one for the old postscript toolchest...

   John Hascall / Iowa State Univ Comp Center / Ames IA

%!
/PROC {
%
% /NAME { #locals begin .... end }  PROC  -
%
	dup dup 0 get 0 exch dict put bind def
} bind def

%
% Create an N-sided regular polygon centered at (X,Y) inscribed in a circle of
% a given radius with the first point "offset" degrees from the X-axis.
%

/Npoly {
%
%  CENTERx CENTERy Radius Offset Width Nsides Npoly  -
%
	11 begin
		/Nsides			exch def
		/Width			exch def
		/Offset			exch def
		/Radius			exch def
		/Y			exch def
		/X			exch def

		/Delta	360 Nsides div	def
		/Angle	0		def
		/i	0		def
		/x	0		def
		/y	0		def

		gsave
			newpath
			0 1 Nsides 1 sub {
				/i exch def
				i Delta mul Offset add /Angle exch def
				Angle cos Radius mul X add /x exch def
				Angle sin Radius mul Y add /y exch def
				i 0 eq {
					x y moveto
				}{
					x y lineto
				} ifelse
			} for
			closepath
			Width setlinewidth
			stroke
		grestore
	end
} PROC

%
%  CENTERx CENTERy Radius Offset Gray Nsides  Npolyfill  -
%  is left as an exercise for the reader
%

% Here is a DEMO

300 300 200   0 3 8 Npoly
350 350 100  15 1 3 Npoly

showpage
Technical Details
Message-ID: <2015@atanasoff.cs.iastate.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!samsung!uunet!dino!atanasoff!atanasoff.cs.iastate.edu!hascall

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!samsung!uunet!dino!atanasoff!atanasoff.cs.iastate.edu!hascall
From: hascall@atanasoff.cs.iastate.edu (John Hascall)
Newsgroups: comp.lang.postscript
Subject: Npoly for your toolchest
Message-ID: <2015@atanasoff.cs.iastate.edu>
Date: 22 Nov 89 22:59:20 GMT
Sender: hascall@atanasoff.cs.iastate.edu
Reply-To: hascall@atanasoff.cs.iastate.edu (John Hascall)
Distribution: na
Organization: Iowa State Univ. Computation Center
Lines: 67