Article View: comp.lang.postscript
Article #1019Re: Building A PostScript Toolset
From: debruyne
Date: Thu, 07 Sep 1989 14:03
Date: Thu, 07 Sep 1989 14:03
101 lines
3706 bytes
3706 bytes
Here are some PostScript routines that can be added to the toolset:
/SelectFontDict 5 dict def
/SelectFont { % call: /font height width angle SelectFont -
SelectFontDict begin
/Angle exch def /Width exch def /Height exch def /Font exch def
/AngleNum Angle sin Angle cos div 12 mul def
Font findfont [Width 0 AngleNum Height 0 0] makefont setfont
end
} bind def % SelectFont
% DEMO
% /Times-Roman 100 40 40 SelectFont
% 30 500 moveto (XYZZY) show
/ShowStrDict 9 dict def
/ShowStr { % call: x y height width angle gray /font (string) ShowStr -
gsave
ShowStrDict begin
/Str exch def /Font exch def /Gray exch def /Angle exch def
/Width exch def /Height exch def /Y1 exch def /X1 exch def
/AngleNum Angle sin Angle cos div 12 mul def
Font findfont [Width 0 AngleNum Height 0 0] makefont setfont
X1 Y1 moveto Gray setgray Str show
end
grestore
} bind def % ShowStr
% DEMO
% 10 400 20 20 0 0.75 /Times-Roman
% (20hght 20wdth 0ang Times-Roman) ShowStr
% 10 360 20 30 20 0.25 /Times-Roman
% (20hght 30wdth 20ang Times-Roman) ShowStr
% 10 320 20 10 40 0.25 /Times-Roman
% (20hght 10wdth 40ang Times-Roman) ShowStr
% 10 280 30 20 330 0.25 /Times-Roman
% (30hght 20wdth 330ang Times-Roman) ShowStr
/ShowStrGrayDict 8 dict def
/ShowStrGray { % call: x y mingray maxgray string ShowStrGray -
% show a string with increasing (decreasing) gray-levels
gsave
ShowStrGrayDict begin
/Str exch def /MaxG exch def /MinG exch def /Y exch def /X exch def
/Step MaxG MinG sub Str length 1 sub div def
/TmpStr 2 string def
X Y moveto
0 1 Str length 1 sub {
/LoopVar exch def
MinG setgray
TmpStr 0 Str LoopVar get put TmpStr show
/MinG MinG Step add def
} for
end
grestore
} bind def % ShowStrGray
% DEMO
% /Times-Roman findfont [30 0 0 40 0 0] makefont setfont
% 30 400 0.0 0.9 (Abcde Fghij Klmno) ShowStrGray
% 30 300 0.9 0.0 (Abcde Fghij Klmno) ShowStrGray
/SquareEmptyDict 6 dict def
/SquareEmpty { % call: xbl ybl xtr ytr gray width SquareEmpty -
% bl = bottom-left, tr = top-right
gsave
SquareEmptyDict begin
/Width exch def /Gray exch def
/Ytr exch def /Xtr exch def /Ybl exch def /Xbl exch def
newpath Xbl Ybl moveto Xtr Ybl lineto Xtr Ytr lineto
Xbl Ytr lineto Xbl Ybl lineto closepath
Width setlinewidth Gray setgray stroke
end
grestore
} bind def % SquareEmpty
% DEMO
% 100 100 300 500 0.75 5 SquareEmpty
/SquareSolidDict 5 dict def
/SquareSolid { % call: xbl ybl xtr ytr gray SquareEmpty -
% bl = bottom-left, tr = top-right
gsave
SquareSolidDict begin
/Gray exch def /Ytr exch def /Xtr exch def /Ybl exch def /Xbl exch def
newpath Xbl Ybl moveto Xtr Ybl lineto Xtr Ytr lineto
Xbl Ytr lineto Xbl Ybl lineto closepath
Gray setgray fill
end
grestore
} bind def % SquareSolid
% DEMO
% 50 400 400 600 0.25 SquareSolid
Please report any remarks and/or bugs to:
Jos de Bruijne
Philips Research Labs Eindhoven,
Holland (The country in Europe, NOT the city in the USA!)
Email: debruyne@prles3.prl.philips.nl
Technical Details
Message-ID:
<683@prles2.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!gem.mps.ohio-state.edu!ginosko!uunet!mcsun!hp4nl!phigate!prle!prles2!prles3.prl.philips.nl!debruyneShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!gem.mps.ohio-state.edu!ginosko!uunet!mcsun!hp4nl!phigate!prle!prles2!prles3.prl.philips.nl!debruyne From: debruyne@prles3.prl.philips.nl Newsgroups: comp.lang.postscript Subject: Re: Building A PostScript Toolset Message-ID: <683@prles2.UUCP> Date: 7 Sep 89 14:03:46 GMT Sender: nobody@prles2.UUCP Reply-To: debruyne@prles3.prl.philips.nl () Organization: Philips Research Laboratories, Eindhoven the Netherlands Lines: 101