Article View: comp.lang.postscript
Article #2230Re: path to calligraphy penstroke
From: Mark A. Rosenstein
Date: Wed, 30 May 1990 02:01
Date: Wed, 30 May 1990 02:01
114 lines
2950 bytes
2950 bytes
I actually wrote a routine at one point to do calligraphy. There are
three operators I defined: penwidth which takes 1 argument and sets
the width of the nib, penangle which takes 1 argument and sets the
angle of the nib, and penstroke, which strokes the current path with a
pen that has the last specified angle and width. Like stroke, it does
a newpath after it has produced its line. Here are the routines and a
sample usage.
-Mark Rosenstein
Constants aren't and Variables wont
----------------
%! penstroke routine
% data is kept in a private dictionary
/pendict 20 dict def
pendict begin
/mtx matrix def
/angle 30 def
/width 1 def
/dx 0 def
/dy 0 def
/trans { dy add exch dx add exch } def
/calculate {
/mtx [ angle cos angle sin dup neg 2 index 0 0 ] def
/dx width 0 mtx transform /dy exch def def
} def
end
% set the current angle of the pen nib
/penangle {
pendict begin
/angle exch def
calculate
end
} bind def
% set the width of the pen nib
/penwidth {
pendict begin
/width exch def
calculate
end
} bind def
% stroke the current path with the current nib
/penstroke { pendict begin
{ /yo exch def
/xo exch def
/xx xo def
/yy yo def
} { gsave
/y exch def
/x exch def
newpath xx yy moveto x y lineto
x y trans lineto
xx yy trans lineto
closepath fill
/xx x def
/yy y def
grestore
} { gsave
/y exch def
/x exch def
/y2 exch def
/x2 exch def
/y1 exch def
/x1 exch def
newpath xx yy moveto x1 y1 x2 y2 x y curveto
x y trans lineto
x2 y2 trans x1 y1 trans xx yy trans curveto
closepath fill
/xx x def
/yy y def
grestore
} { gsave
newpath xx yy moveto xo yo lineto
xo yo trans lineto
xx yy trans lineto
closepath fill
/xx xo def
/yy yo def
grestore
} pathforall
newpath
end } bind def
% Here is some sample usage:
/inch { 72 mul } def
10 penwidth 30 penangle
1 inch 2 inch translate
0 0 moveto 0 1 inch lineto
.5 inch 0 lineto
.5 inch 1 inch lineto penstroke
1.5 inch 0 moveto
1.5 inch .5 inch .5 inch -90 270 arc
closepath penstroke
2 inch 0 moveto
2.6 inch 1 inch lineto
3.2 inch 0 lineto
closepath penstroke
1 inch 4 inch moveto
/Helvetica findfont 1 inch scalefont setfont
(TESTING) false charpath penstroke
showpage
Technical Details
Message-ID:
<1990May30.020154.7416@athena.mit.edu>Path:
arc1-ca.pugleaf.net!utzoo!yunexus!hydroesm!jtsv16!torsqnt!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!snorkelwacker!bloom-beacon!athena.mit.edu!marReferences:
<12041@june.cs.washington.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!yunexus!hydroesm!jtsv16!torsqnt!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!snorkelwacker!bloom-beacon!athena.mit.edu!mar From: mar@athena.mit.edu (Mark A. Rosenstein) Newsgroups: comp.lang.postscript Subject: Re: path to calligraphy penstroke Message-ID: <1990May30.020154.7416@athena.mit.edu> Date: 30 May 90 02:01:54 GMT Article-I.D.: athena.1990May30.020154.7416 References: <12041@june.cs.washington.edu> Sender: news@athena.mit.edu (News system) Reply-To: mar@athena.mit.edu (Mark A. Rosenstein) Organization: Massachusetts Institute of Technology Lines: 114