File:  [NeXTSTEP 3.3 examples] / Examples / PostScript / Compositing.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: Compositing.eps
%%Creator: NeXT
%%Pages: 0 1
%%BoundingBox: 0 0 360 772
%%DocumentFonts: Helvetica
%%EndComments


% A simple demo of the various compositing modes on the
% NeXT computer. Change the alpha and gray values (below) 
% and the source and destination draw procedures if you wish
% to experiment further.

/thisGstate gstate def

% Change the following for experimentation purposes...

/sourceGray 0.333 def
/sourceAlpha 1.0 def
/destGray 0.667 def
/destAlpha 1.0 def

% Some other parameters that probably need not be changed

/fontSize 12 def
/sourceX 40 def /sourceY 10 def 
/destX 200 def /destY 10 def 
/width 120 def /height 32 def
/titleOffset height 4 add def
/opY destY height add fontSize add 20 add def
/opYDelta height fontSize add 10 add def
/opX 115 def

% Font 

/Helvetica findfont fontSize scalefont setfont

% Procedure to draw the destination; change this for different images

/drawDest {
	1.0 setgray 0.0 setalpha 
	destX destY width height rectfill
	newpath
	destX width add destY moveto
	0 height rlineto
	width neg 0 rlineto
	closepath
	destGray setgray 
	destAlpha setalpha
	fill
	destX destY titleOffset add moveto
	0.0 setgray 1.0 setalpha (Destination) show
	0 setlinewidth destX destY width height rectstroke
} def	
	
% Procedure to draw the source; changing this might be fun as well

/drawSource {
	1.0 setgray 0.0 setalpha 
	sourceX sourceY width height rectfill
	newpath
	sourceX sourceY moveto
	0 height rlineto
	width 0 rlineto
	closepath
	sourceGray setgray 
	sourceAlpha setalpha
	fill
	sourceX sourceY titleOffset add moveto
	0.0 setgray 1.0 setalpha (Source) show
	0 setlinewidth sourceX sourceY width height rectstroke
} def	

% Procedure to perform one compositing operator

/showComp {    % name destx desty operator showComp
	/op exch def
	/dy exch def
	/dx exch def

	% Bring the destination picture over
	destX destY width height thisGstate dx dy Copy composite

	% Composite the source on top of it
	sourceX sourceY width height thisGstate dx dy op composite

	% Write the name
	dx dy titleOffset add moveto
	0.0 setgray 1.0 setalpha show
	0 setlinewidth dx dy width height rectstroke
} def

drawDest
drawSource

/compositeOps [(Copy) (Clear) (Sover) (Dover) (Sin) (Din) 
(Sout) (Dout) (Satop) (Datop) (Xor) (PlusD) (PlusL)] def


% Run in a loop and do a composite with each of the above
% operators...

/curX opX def
/curY opY def

0 1 12 {
  compositeOps exch get dup 	% Now we have two strings
  cvx exec curX curY 3 -1 roll	% (name) x y op
  showComp
  /curY curY opYDelta add def
} for

unix.superglobalmegacorp.com

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