Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Centering generated content

Status
Not open for further replies.

jonArk

Technical User
Feb 9, 2011
1
GB
Hi I'm completely new to PS and would really appreciate some advice.

I have a PS which generates a design and creates a PDF but it centers the design to the bottom left of the file and omits the other 3/4. Can anyone help please?

The Code is:


%!PS

/golden 137.50776 def % super dooper magic number.
/rate 18 360 div def % base spiral expansion rate
/divergence 0.5 def % exponent - 1.0 is linear, 0.5 is best
/sweep 160000 def % total number of degrees in spiral
/inside 0 golden mul def % size of hole in middle
/dotrad 0.2 def % size of seeds
/dot1 {newpath dotrad 0 360 arc fill} def % dot utility routine
/fixpack {dup 0 ge {divergence exp} {neg % packing utility routine
divergence exp neg} ifelse} def
/drawsunflower {inside golden sweep { % start for loop
dup dup rate mul fixpack % copy vector
exch cos mul exch dup % find & save x position
rate mul fixpack exch sin mul % find y position
dot1 } for } def % draw dot; end loop & proc
drawsunflower % draw the sunflower
showpage quit % and print it
 
For the pattern centred on A4:

%!PS

/mm { 72 25.4 div mul } def % mm to points
/paperwidth { 210 mm } def % paper width 210mm A4 width
/paperlength { paperwidth 2 sqrt mul } def % paper length A4 length
/setscale { 2 2 scale } def % set scaling
/settranslate { paperwidth 2 div paperlength 2 div translate } def % translate to centre
/golden 137.50776 def % super dooper magic number.
/rate 18 360 div def % base spiral expansion rate
/divergence 0.5 def % exponent - 1.0 is linear, 0.5 is best
/sweep 160000 def % total number of degrees in spiral
/inside 0 golden mul def % size of hole in middle
/dotrad 0.2 def % size of seeds
/dot1 {newpath dotrad 0 360 arc fill} def % dot utility routine
/fixpack {dup 0 ge {divergence exp} {neg % packing utility routine
divergence exp neg} ifelse} def
/drawsunflower { inside golden sweep { % start for loop
dup dup rate mul fixpack % copy vector
exch cos mul exch dup % find & save x position
rate mul fixpack exch sin mul % find y position
dot1 } for } def % draw dot; end loop & proc
settranslate
setscale
drawsunflower % draw the sunflower
showpage quit % and print it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top