• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Total PostScript Newbie Questions

New Here ,
Mar 09, 2014 Mar 09, 2014

Copy link to clipboard

Copied

I've just started learning PostScript and I'm going through a couple tutorials.  (I'm finding this frustrating since they either tend to take pages to get into things slowly or they assume I already know what they're talking about.)

I've copied and pasted the text from http://www.cups.org/documentation.php/doc-1.5/spec-postscript.html into a file and saved it as a .ps file.  I'm on the latest version of OS X (10.0.2).  I've installed Ghostscript, but that does not seem to display output and when I've tried to write to png files, I don't get output.  (I'm figuring Ghostscript must need a final "write to file" command to actually write to an output file, but finding a good Ghostscript command reference is hard.)

So for now I'm stuck using the built in Preview on OS X, and that may be part of the problem.

I've added this text:

% Add some text

/showGorilla % stack: x y ---

{ moveto (Gorilla) show }def

/Times-Roman findfont 6 scalefont setfont

72 300 showGorilla

/Times-Roman findfont 10 scalefont setfont

72 275 showGorilla

/Times-Roman findfont 15 scalefont setfont

72 250 showGorilla

/Times-Roman findfont 20 scalefont setfont

72 225 showGorilla

to the file I liked to above (I've included the full text at the bottom of this post).  It works.

But I have two questions:

1) The commands specify a 2" circle for the smiley face and it comes out to be 4".  Even in the picture provided on the source page, the smiley face circle appears to be about the same proportion (on the page) as I get when I view the file.  If I change the diameter of the circle to 4", it becomes an 8" circle.  Why is the size of all the graphical objects doubled when I view or print this file?

2) I was exerpimenting with rotate and added "90 rotate" before the word "Gorilla" is to be printed and the result was no text at all.  Then I put it in before the circle for the smiley face, but the only effect was that everything after wherever I put the "90 rotate" command was no longer visible.  What am I doing wrong?  Eventually I'd like to be able to specify, in the ps file, if I'm printing landscape instead of portrait and, from what I've seen, there seems to be no way to do that other than to use rotate and to set the page size accordingly.  Are there better ways to do that?


Here is the full file, with the text for writing "Gorilla" included:

%!PS-Adobe-3.0

%%BoundingBox: 36 36 576 756

%%Pages: 1

%%LanguageLevel: 2

%%EndComments

%%BeginSetup

% this is where fonts would be embedded

%%EndSetup

%%Page: (1) 1

%%BeginPageSetup

% this is where page-specific features would be specified

%%EndPageSetup

% Draw a black box around the page

0 setgray

1 setlinewidth

36 36 540 720 rectstroke

% Draw a two inch blue circle in the middle of the page

0 0 1 setrgbcolor

306 396 144 0 360 arc closepath fill

 

% Draw two half inch yellow circles for eyes

1 1 0 setrgbcolor

252 432 36 0 360 arc closepath fill

360 432 36 0 360 arc closepath fill

 

% Draw the smile

1 setlinecap

18 setlinewidth

306 396 99 200 340 arc stroke

 

% Add some text

/showGorilla % stack: x y ---

{ moveto (Gorilla) show }def

 

/Times-Roman findfont 6 scalefont setfont

72 300 showGorilla

/Times-Roman findfont 10 scalefont setfont

72 275 showGorilla

/Times-Roman findfont 15 scalefont setfont

72 250 showGorilla

/Times-Roman findfont 20 scalefont setfont

72 225 showGorilla

   

% Print it!

showpage

%%EOF

TOPICS
Programming

Views

600

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 11, 2014 Mar 11, 2014

Copy link to clipboard

Copied

LATEST

1. Radius, not diameter.

2. 90 rotate rotates around the origin. Take a piece of paper and put it on a book. Now rotate the paper 90 degrees around the bottom left corner. How much of the paper is now overlapping the book. (The answer should be "none"). Same problem. Combine with "translate".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines