File:  [NeXTSTEP 3.3 examples] / Examples / PostScript / Level2Stars.eps
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:49:00 2018 UTC (8 years, 1 month ago) by root
Branches: NeXT, MAIN
CVS tags: NeXTSTEP33, HEAD
Sample Programs from NeXSTEP 3.3

%!PS-Adobe-2.0 EPSF-2.0
%%Title: Level2Stars.eps
%%Creator: Ali Ozer
%%CreationDate: Fri May 29 14:00:03 1992
%%BoundingBox: 0 0 600 200
%%DocumentFonts: Times-BoldItalic
%%EndComments

% First check to see if this device is Level II

/DeviceIsLevel2
    systemdict /languagelevel known {languagelevel 2 ge} {false} ifelse
def

DeviceIsLevel2 {	% A PostScript Level 2 device

    % Star code mostly from chapter 4 of the Second Edition
    % of the PostScript Language Reference Manual
    
    8 dict dup begin
	/PatternType    1 def
	/PaintType      1 def
	/TilingType     1 def
	/BBox           [0 0 40 40] def
	/XStep          40 def
	/YStep          40 def
	/star		{
	    gsave 0 8 moveto 4 {144 rotate 0 8 lineto} repeat
	    closepath fill grestore
	} def
	/PaintProc      {
	    begin
	    0.333 setgray 0 0 40 40 rectfill
	    1.0 0.0 0.0 setrgbcolor 10 10 translate star
	    0.0 1.0 0.0 setrgbcolor 0 20 translate star
	    0.0 0.0 1.0 setrgbcolor 20 -20 translate star
	    1.0 1.0 0.0 setrgbcolor 0 20 translate star
	    end
	} def
    end
    matrix makepattern
    /starpattern exch def

    /setStarPattern {
        starpattern setpattern
    } def     

} {	% Not a PostScript Level 2 device!
    
    /setStarPattern {	% We have to fake the pattern
        0.5 setgray
    } def     

} ifelse

/centerText {	% (str) y w centerText -
    2 index stringwidth	% (str) y w wx wy
    pop sub 2 div	% (str) y (w-wx)/2
    exch moveto		% (str)
    show
} def

0.333 setgray
/Times-BoldItalic findfont 24 scalefont setfont
(If the text below is filled with stars, then this is a) 170 600 centerText
(device) 10 600 centerText

setStarPattern
/Times-BoldItalic findfont 160 scalefont setfont
(Level 2) 40 600 centerText

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.