home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NeXTSTEP 3.0
/
NeXTSTEP3.0.iso
/
NextDeveloper
/
Examples
/
AppKit
/
BusyBox
/
Gauge.psw
< prev
next >
Wrap
Text File
|
1990-10-26
|
2KB
|
93 lines
/*
* Gauge.psw, Postscript code for drawing analog gauge.
* 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.
* 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.
*/
/* PSWdrawBorder draws the border and background of the gauge face.
*/
defineps PSWdrawBorder(float x; float y; float radius)
0.835 setgray
x y radius 1.5 add 0 360 arc
fill
1.0 setlinewidth
1.0 setgray
x y radius 2 add 50 220 arc
stroke
1.5 setlinewidth
.333 setgray
x y radius 2 add 220 50 arc
stroke
1.0 setlinewidth
0.0 setgray
x y radius 1.5 add 220 50 arc
stroke
endps
/* PSWdrawTicks draws a tick mark at each increment around the circle
* from the start to the stop angle.
*/
defineps PSWdrawTicks(float x; float y; float radius; float increment; float start; float stop)
0 setgray
.5 setlinewidth
gsave
x y translate
start rotate
start increment stop {
newpath
radius 0 moveto
-3 0 rlineto
closepath
stroke
increment neg rotate
} for
grestore
endps
/* PSWdrawString simply draws string at specific location
*/
defineps PSWdraw(Ing(float x; float y; char *str)
0 setgray
x y moveto
(str) show
endps
/* PSWmakeHand defines a PS function that will subsequently be used
* to draw the hand at different angles as the value changes.
*/
defineps PSWmakeHand(float length)
/mhand {
0 setgray
0 setlinewidth
newpath
0 3.5 moveto
0 0 3.5 90 270 arc
length 3.5 rlineto
length neg 3.5 rlineto
closepath
fill
newpath
0 2 moveto
0 0 1.5 0 360 arc
closepath
1 setgray
closepath
fill
} def
endps
/* PSWdrawHand translate and rotates the coordinate system, then uses
* mhand to draw the gauge hand.
*/
defineps PSWdrawHand(float x; float y; float ang)
gsave
x y translate
ang rotate
mhand
grestore
endps