home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NeXTSTEP 3.0
/
NeXTSTEP3.0.iso
/
NextDeveloper
/
Examples
/
AppKit
/
BusyBox
/
Clock.psw
< prev
next >
Wrap
Text File
|
1990-10-26
|
3KB
|
138 lines
/*
* Clock.psw, Postscript code for drawing analog, digital and sundial clocks.
* Author: Bruce Blumberg, NeXT Developer Support Group.
* Originally written for 0.6 mid 1988, modified for 1.0 by Ali Ozer.
* Cleaned and spiffed up for 2.0 by Julie Zelenski, goddess of the sundial.
* You may freely copy, distribute and reuse the code in this example.
* NeXT disclaims any warranty of any kind, expressed or implied, as to its
* fitness for any particular use.
*/
/* drawClockHand draws a line with the specified width and color.
* The line starts at 0, 0 and spans the specified length in the
* direction specified by angle. Despite its name, this function is
* a pretty generic line drawer.
*/
defineps PSWdrawClockHand (float x; float y; float angle; float length; float gray; float width)
gsave
x y translate
angle rotate
0 0 moveto 0 length lineto
width setlinewidth
gray setgray
stroke
grestore
endps
/* drawAnalogFace draws the circular border and draws tick marks at
* 3,6,9 and 12
*/
defineps PSWdrawAnalogFace (float x; float y; float radius)
gsave
x y translate
1.0 setlinewidth
1.0 setgray
1 0 radius 0 360 arc
stroke
.333 setgray
0 0 radius 0 360 arc
stroke
/tickLen radius 8 div neg def
1 1 4 {
.333 setgray
radius 0.5 moveto
tickLen 0 rlineto
stroke
1.0 setgray
radius -.5 moveto
tickLen 0 rlineto
stroke
90 rotate
} for
grestore
endps
/* drawSundialFace scales coordinate system to draw ellipse. Draws tick marks
* around the border every pi/2 degrees.
*/
defineps PSWdrawSundialFace (float x; float y; float rad(P
gsave
x y translate
1.6 .45 scale
0 setlinewidth
.176 setgray
0 -5 radius 0 360 arc fill
.835 setgray
0 0 radius 1 sub 0 360 arc fill
.333 setgray
0 0 radius 0 360 arc stroke
/tickLen radius 4 div neg def
1 1 8 {
1.0 setgray
radius -.5 moveto
tickLen 0 rlineto stroke
.333 setgray
radius 0.5 moveto
tickLen 0 rlineto stroke
45 rotate
} for
grestore
endps
/* drawShadow draws the shadow of the sundial marker.
*/
defineps PSWdrawShadow (float cx; float cy; float x; float y; float triangle)
gsave
cx cy translate
1.6 .45 scale
triangle neg 0 moveto
.333 setgray
1.5 setlinewidth
x y lineto
triangle 0 lineto
stroke
triangle neg 0 moveto
0 setgray
0.5 setlinewidth
0 triangle 11 mul lineto
triangle 0 lineto
stroke
grestore
endps
/* drawSweep draws the second hand for the sundial (in the translated
* and scaled coordinate system.
*/
defineps PSWdrawSweep (float x; float y; float angle;float length)
gsave
x y translate
1.6 .45 scale
angle rotate
0 0 moveto 0 length lineto
0 setlinewidth
0 setgray
stroke
grestore
endps
/* centerShow centers the width of a string at the specific x y location
* using specified gray
*/
defineps PSWcenterShow (float x; float y; char *str; float gray)
gray setgray
x (str) stringwidth pop 2 div sub y moveto
(str) show
stroke
endps