Annotation of Examples/AppKit/SortingInAction/SortWraps.psw, revision 1.1.1.1

1.1       root        1:  
                      2: /* Collection of PSwrap functions for animating sorting activity.
                      3:  * 
                      4:  * Author: Julie Zelenski, NeXT Developer Support
                      5:  * You may freely copy, distribute and reuse the code in this example.  
                      6:  * NeXT disclaims any warranty of any kind, expressed or implied, as to 
                      7:  * its fitness for any particular use.
                      8:  */
                      9: 
                     10: 
                     11: 
                     12: /* PSWswapRects sets the gray to white, fills the white rectangle, sets the 
                     13:  * gray to black, fills the black rectangle, and flushes the drawing to 
                     14:  * the screen immediately.
                     15:  */
                     16: defineps PSWswapRects (float x1, y1, x2, y2, width, height)
                     17:     0.0 setgray
                     18:     x1 y1 width height rectfill
                     19:     1.0 setgray
                     20:     x2 y2 width height rectfill
                     21:     flushgraphics
                     22: endps
                     23: 
                     24: 
                     25: /* PSWmoveRects sets the gray appropriately (gray value is passed as parameter)
                     26:  * fills the rectangle and flushes the drawing to the screen immediately.
                     27:  */
                     28: defineps PSWmoveRect (float x, y, width, height, gray)
                     29:     gray setgray
                     30:     x y width height rectfill
                     31:     flushgraphics
                     32: endps
                     33: 
                     34: 
                     35: /* PSWcompareRects turns on instance drawing, sets the gray to light gray,
                     36:  * fills the two rectangles being compared and turns off instance drawing.
                     37:  */
                     38: defineps PSWcompareRects (float x1,y1,width,height1,x2,y2,height2)   
                     39:     true setinstance
                     40:     .667 setgray    
                     41:     x1 y1 width height1 rectfill
                     42:     x2 y2 width height2 rectfill    
                     43:     false setinstance
                     44: endps
                     45: 
                     46: 
                     47: /* PSWfade simply sovers a semi-transparent white rectangle onto the view to
                     48:  * "fade" the background. 
                     49:  */
                     50: defineps PSWfade(float width, height)
                     51:     1.0 setgray
                     52:     .75 setalpha
                     53:     0 0 width height Sover compositerect
                     54: endps
                     55:     
                     56:     
                     57: /* PSWdrawBorder strokes the rectangle border in black.
                     58:  */
                     59: defineps PSWdrawBorder(float width, height)    
                     60:     0.0 setgray
                     61:     1.0 setalpha
                     62:     1.0 setlinewidth
                     63:     0.0 0.0 width height rectstroke
                     64: endps
                     65: 
                     66: 
                     67: /* PSWdrawName shows the sort name at the specified location.
                     68:  */
                     69: defineps PSWdrawName(float x, y; char *name)
                     70:     0.0 setgray
                     71:     1.0 setalpha
                     72:     x y moveto
                     73:    (name) show
                     74: endps
                     75: 
                     76: 
                     77: /* PSWdrawStrings is used to draw four right-aligned strings at a 
                     78:  * specific height.
                     79:  */
                     80: defineps PSWdrawStrings (char *s1, *s2, *s3, *s4; float height)
                     81:     /rightShow {dup stringwidth pop neg 0 rmoveto show} def
                     82:     0.0 setgray
                     83:     1.0 setalpha
                     84:     140.0 height moveto
                     85:     (s1) rightShow
                     86:     270.0 height moveto
                     87:     (s2) rightShow
                     88:     370.0 height moveto
                     89:     (s3) rightShow
                     90:     480.0 height moveto
                     91:     (s4) rightShow
                     92: endps
                     93: 
                     94:     

unix.superglobalmegacorp.com

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