Article View: comp.lang.postscript
Article #1496ruler.ps - an inch/point ruler of your very own
From: Brian Bartholomew
Date: Sat, 13 Jan 1990 23:29
Date: Sat, 13 Jan 1990 23:29
173 lines
4990 bytes
4990 bytes
In an attempt to RAISE the signal to noise (s/n) ratio, I am posting
code for a point/inch ruler. To make the most use of it, load your
laserprinter with transparencies designed for xerox copiers. All the
ones that I have seen have an opaque white bar along one long edge,
as well as a certain "tacky" feel.
"Any sufficiently advanced technology is indistinguishable from a rigged demo."
-------------------------------------------------------------------------------
Brian Bartholomew UUCP: ...gatech!uflorida!beach.cis.ufl.edu!bb
University of Florida Internet: bb@beach.cis.ufl.edu
----- CUT HERE ----- CUT HERE ----- CUT HERE ----- CUT HERE ----- CUT HERE ----
%!
%!Creator: bb@beach.cis.ufl.edu - 12/30/89.
%
% This program is Copyright 1989 by Brian Bartholomew. It may be used,
% modified, or copied, as long as it is not for direct commercial advantage.
% Please send any interesting modifications to me at b@beach.cis.ufl.edu.
%
%
% I wrote this file while learning Postscript, in an attempt to get a handle
% on exactly how big a point is. It prints what looks like a measuring
% ruler that shows 12 inches on one edge, and the matching number of points
% on the other edge. It prints the ruler diagonally on the page, to allow
% a 12 inch ruler to fit on a 11 inch page. The actual rotation angle is
% very touchy - if you change it half a degree in either direction, the
% ends of the ruler are clipped a bit, at least on this Apple LW NT II.
% Share and enjoy.
%
%
% 12-inch point ruler. Prints diagonally to fit on an 8.5" x 11" page.
%
/pointruler {
% origin is at ruler's top left corner
save
currentpoint translate % make (0,0) be right where we are
newpath
0 0 moveto
% box around ruler
gsave
0.5 setlinewidth
900 0 rlineto
0 -72 rlineto
-900 0 rlineto
closepath
stroke
grestore
/Helvetica-Narrow findfont 12 scalefont setfont
% point scale
gsave
18 0 moveto % move off edge of ruler box, at top
17 pointscale
grestore
% inch scale
gsave
18 -72 moveto % move off edge of ruler box, at bottom
12 inchscale
grestore
% label the ruler
gsave
/Bookman-Demi findfont 12 scalefont setfont
(Point/Inch Ruler - Courtesy of bb@beach.cis.ufl.edu)
dup stringwidth pop 2 div neg 450 add -40 moveto show
grestore
restore
} bind def
/pointscale { % stack: number of 50 point increments
% make the loop args
dup % extra copy for the last label
0 1
3 -1 roll
1 sub % fencepost error fix
{
% first, the label
gsave
-2.5 -25 rmoveto
50 mul % change the for loop index to points count
5 string % change the number to a string
cvs
show
grestore
% next, the increments for 50 points of scale
gsave 0.75 setlinewidth 0 -14 rlineto stroke grestore
10 0 rmoveto
0.25 setlinewidth
4 {
gsave 0 -7 rlineto stroke grestore
10 0 rmoveto
} repeat
} for
% end line and label
0.75 setlinewidth
gsave 0 -14 rlineto stroke grestore
-2.5 -25 rmoveto
50 mul % change the for loop index to points count
5 string % change the number to a string
cvs
show
} bind def
/inchscale { % stack: number of inches
% make the loop args
dup % extra copy for the last label
0 1
3 -1 roll
1 sub % fencepost error fix
{
% first, the label
gsave
-2.5 17 rmoveto
4 string % change the for loop counter to a string
cvs
show
grestore
% next, the increments for 1 inch of scale
gsave 0.75 setlinewidth 0 14 rlineto stroke grestore
9 0 rmoveto % 1/8" = 9.0 points
0.25 setlinewidth
3 {
gsave 0 7 rlineto stroke grestore
9 0 rmoveto
} repeat
0.75 setlinewidth
gsave 0 10.5 rlineto stroke grestore
0.25 setlinewidth
9 0 rmoveto
3 {
gsave 0 7 rlineto stroke grestore
9 0 rmoveto
} repeat
} for
% end line and label
0.75 setlinewidth
gsave 0 14 rlineto stroke grestore
-2.5 17 rmoveto
4 string % change the for loop counter to a string
cvs
show
} bind def
306 396 translate % go to center of page
54.5 rotate % touchy - a bit past the paper's diagonal
-450 36 moveto % move towards corner to place ruler
pointruler
showpage
--
"Any sufficiently advanced technology is indistinguishable from a rigged demo."
-------------------------------------------------------------------------------
Brian Bartholomew UUCP: ...gatech!uflorida!beach.cis.ufl.edu!bb
University of Florida Internet: bb@beach.cis.ufl.edu
Technical Details
Message-ID:
<21772@uflorida.cis.ufl.EDU>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!usc!apple!ames!ncar!mephisto!uflorida!swamp.cis.ufl.edu!bbShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!usc!apple!ames!ncar!mephisto!uflorida!swamp.cis.ufl.edu!bb From: bb@swamp.cis.ufl.edu (Brian Bartholomew) Newsgroups: comp.lang.postscript Subject: ruler.ps - an inch/point ruler of your very own Message-ID: <21772@uflorida.cis.ufl.EDU> Date: 13 Jan 90 23:29:55 GMT Sender: news@uflorida.cis.ufl.EDU Reply-To: bb@swamp.cis.ufl.edu () Organization: UF CIS Department Lines: 173