Annotation of Examples/AppKit/BusyBox/Clock.psw, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Clock.psw, Postscript code for drawing analog, digital and sundial clocks.
                      3:  * Author: Bruce Blumberg, NeXT Developer Support Group.
                      4:  * Originally written for 0.6 mid 1988, modified for 1.0 by Ali Ozer.
                      5:  * Cleaned and spiffed up for 2.0 by Julie Zelenski, goddess of the sundial.
                      6:  * You may freely copy, distribute and reuse the code in this example.  
                      7:  * NeXT disclaims any warranty of any kind, expressed or implied, as to its 
                      8:  * fitness for any particular use.
                      9:  */
                     10: 
                     11: 
                     12: /* drawClockHand draws a line with the specified width and color. 
                     13:  * The line starts at 0, 0 and spans the specified length in the 
                     14:  * direction specified by angle. Despite its name, this function is
                     15:  * a pretty generic line drawer.
                     16: */
                     17: defineps PSWdrawClockHand (float x; float y; float angle; float length; float gray; float width)
                     18:        gsave
                     19:        x y translate
                     20:        angle rotate
                     21:        0 0 moveto 0 length lineto 
                     22:        width setlinewidth
                     23:        gray setgray
                     24:        stroke
                     25:        grestore
                     26: endps
                     27: 
                     28: 
                     29: /* drawAnalogFace draws the circular border and draws tick marks at
                     30:  * 3,6,9 and 12
                     31:  */
                     32: defineps PSWdrawAnalogFace (float x; float y; float radius)
                     33:        gsave 
                     34:        x y translate
                     35:        1.0 setlinewidth
                     36:        1.0 setgray
                     37:        1 0 radius 0 360 arc
                     38:        stroke
                     39: 
                     40:        .333 setgray
                     41:        0 0 radius 0 360 arc
                     42:        stroke
                     43:        
                     44:        /tickLen radius 8 div neg def
                     45:        1 1 4 {
                     46:                .333 setgray
                     47:                radius 0.5 moveto
                     48:                tickLen 0 rlineto
                     49:                stroke 
                     50:                1.0 setgray
                     51:                radius -.5 moveto
                     52:                tickLen 0 rlineto
                     53:                stroke 
                     54:                90 rotate
                     55:        } for
                     56:        grestore
                     57: endps
                     58: 
                     59: /* drawSundialFace scales coordinate system to draw ellipse.  Draws tick marks
                     60:  * around the border every pi/2 degrees.
                     61:  */
                     62: defineps PSWdrawSundialFace (float x; float y; float radius)
                     63:        gsave
                     64:        x y translate 
                     65:        1.6 .45 scale
                     66:        0 setlinewidth
                     67:        .176 setgray
                     68:        0 -5 radius 0 360 arc fill
                     69:        .835 setgray
                     70:        0 0 radius 1 sub 0 360 arc fill
                     71:        .333 setgray
                     72:        0 0 radius 0 360 arc stroke
                     73: 
                     74:        /tickLen radius 4 div neg def
                     75:        1 1 8 {
                     76:                1.0 setgray
                     77:                radius -.5 moveto
                     78:                tickLen 0 rlineto stroke 
                     79:                .333 setgray
                     80:                radius 0.5 moveto
                     81:                tickLen 0 rlineto stroke 
                     82:                45 rotate
                     83:        } for
                     84:        grestore
                     85: endps
                     86: 
                     87: /* drawShadow draws the shadow of the sundial marker.
                     88:  */
                     89: defineps PSWdrawShadow (float cx; float cy; float x; float y; float triangle)
                     90:        gsave
                     91:        cx cy translate
                     92:        1.6 .45 scale
                     93:        
                     94:        triangle neg 0 moveto
                     95:        .333 setgray
                     96:        1.5 setlinewidth
                     97:        x y lineto
                     98:        triangle 0 lineto
                     99:        stroke
                    100: 
                    101:        triangle neg 0 moveto
                    102:        0 setgray
                    103:        0.5 setlinewidth
                    104:        0 triangle 11 mul lineto
                    105:        triangle 0 lineto
                    106:        stroke
                    107:        grestore
                    108: endps
                    109: 
                    110: 
                    111: /* drawSweep draws the second hand for the sundial (in the translated
                    112:  * and scaled coordinate system.
                    113:  */
                    114: defineps PSWdrawSweep (float x; float y; float angle;float length)
                    115:        gsave
                    116:        x y translate
                    117:        1.6 .45 scale
                    118:        angle rotate
                    119:        0 0 moveto 0 length lineto 
                    120:        0 setlinewidth
                    121:        0 setgray
                    122:        stroke
                    123:        grestore
                    124: endps
                    125: 
                    126: /* centerShow centers the width of a string at the specific x y location 
                    127:  * using specified gray
                    128:  */ 
                    129: defineps PSWcenterShow (float x; float y; char *str; float gray)
                    130:        gray setgray
                    131:        x (str) stringwidth pop 2 div sub y moveto
                    132:        (str) show
                    133:        stroke
                    134: endps
                    135: 
                    136: 
                    137: 

unix.superglobalmegacorp.com

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