Annotation of Examples/PostScript/Compositing.eps, revision 1.1.1.1

1.1       root        1: %!PS-Adobe-2.0 EPSF-2.0
                      2: %%Title: Compositing.eps
                      3: %%Creator: NeXT
                      4: %%Pages: 0 1
                      5: %%BoundingBox: 0 0 360 772
                      6: %%DocumentFonts: Helvetica
                      7: %%EndComments
                      8: 
                      9: 
                     10: % A simple demo of the various compositing modes on the
                     11: % NeXT computer. Change the alpha and gray values (below) 
                     12: % and the source and destination draw procedures if you wish
                     13: % to experiment further.
                     14: 
                     15: /thisGstate gstate def
                     16: 
                     17: % Change the following for experimentation purposes...
                     18: 
                     19: /sourceGray 0.333 def
                     20: /sourceAlpha 1.0 def
                     21: /destGray 0.667 def
                     22: /destAlpha 1.0 def
                     23: 
                     24: % Some other parameters that probably need not be changed
                     25: 
                     26: /fontSize 12 def
                     27: /sourceX 40 def /sourceY 10 def 
                     28: /destX 200 def /destY 10 def 
                     29: /width 120 def /height 32 def
                     30: /titleOffset height 4 add def
                     31: /opY destY height add fontSize add 20 add def
                     32: /opYDelta height fontSize add 10 add def
                     33: /opX 115 def
                     34: 
                     35: % Font 
                     36: 
                     37: /Helvetica findfont fontSize scalefont setfont
                     38: 
                     39: % Procedure to draw the destination; change this for different images
                     40: 
                     41: /drawDest {
                     42:        1.0 setgray 0.0 setalpha 
                     43:        destX destY width height rectfill
                     44:        newpath
                     45:        destX width add destY moveto
                     46:        0 height rlineto
                     47:        width neg 0 rlineto
                     48:        closepath
                     49:        destGray setgray 
                     50:        destAlpha setalpha
                     51:        fill
                     52:        destX destY titleOffset add moveto
                     53:        0.0 setgray 1.0 setalpha (Destination) show
                     54:        0 setlinewidth destX destY width height rectstroke
                     55: } def  
                     56:        
                     57: % Procedure to draw the source; changing this might be fun as well
                     58: 
                     59: /drawSource {
                     60:        1.0 setgray 0.0 setalpha 
                     61:        sourceX sourceY width height rectfill
                     62:        newpath
                     63:        sourceX sourceY moveto
                     64:        0 height rlineto
                     65:        width 0 rlineto
                     66:        closepath
                     67:        sourceGray setgray 
                     68:        sourceAlpha setalpha
                     69:        fill
                     70:        sourceX sourceY titleOffset add moveto
                     71:        0.0 setgray 1.0 setalpha (Source) show
                     72:        0 setlinewidth sourceX sourceY width height rectstroke
                     73: } def  
                     74: 
                     75: % Procedure to perform one compositing operator
                     76: 
                     77: /showComp {    % name destx desty operator showComp
                     78:        /op exch def
                     79:        /dy exch def
                     80:        /dx exch def
                     81: 
                     82:        % Bring the destination picture over
                     83:        destX destY width height thisGstate dx dy Copy composite
                     84: 
                     85:        % Composite the source on top of it
                     86:        sourceX sourceY width height thisGstate dx dy op composite
                     87: 
                     88:        % Write the name
                     89:        dx dy titleOffset add moveto
                     90:        0.0 setgray 1.0 setalpha show
                     91:        0 setlinewidth dx dy width height rectstroke
                     92: } def
                     93: 
                     94: drawDest
                     95: drawSource
                     96: 
                     97: /compositeOps [(Copy) (Clear) (Sover) (Dover) (Sin) (Din) 
                     98: (Sout) (Dout) (Satop) (Datop) (Xor) (PlusD) (PlusL)] def
                     99: 
                    100: 
                    101: % Run in a loop and do a composite with each of the above
                    102: % operators...
                    103: 
                    104: /curX opX def
                    105: /curY opY def
                    106: 
                    107: 0 1 12 {
                    108:   compositeOps exch get dup    % Now we have two strings
                    109:   cvx exec curX curY 3 -1 roll % (name) x y op
                    110:   showComp
                    111:   /curY curY opYDelta add def
                    112: } for

unix.superglobalmegacorp.com

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