|
|
1.1 ! root 1: /* ! 2: * Gauge.psw, Postscript code for drawing analog gauge. ! 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. ! 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 ! 8: * its fitness for any particular use. ! 9: */ ! 10: ! 11: /* PSWdrawBorder draws the border and background of the gauge face. ! 12: */ ! 13: defineps PSWdrawBorder(float x; float y; float radius) ! 14: 0.835 setgray ! 15: x y radius 1.5 add 0 360 arc ! 16: fill ! 17: 1.0 setlinewidth ! 18: 1.0 setgray ! 19: x y radius 2 add 50 220 arc ! 20: stroke ! 21: 1.5 setlinewidth ! 22: .333 setgray ! 23: x y radius 2 add 220 50 arc ! 24: stroke ! 25: 1.0 setlinewidth ! 26: 0.0 setgray ! 27: x y radius 1.5 add 220 50 arc ! 28: stroke ! 29: endps ! 30: ! 31: /* PSWdrawTicks draws a tick mark at each increment around the circle ! 32: * from the start to the stop angle. ! 33: */ ! 34: defineps PSWdrawTicks(float x; float y; float radius; float increment; float start; float stop) ! 35: 0 setgray ! 36: .5 setlinewidth ! 37: gsave ! 38: x y translate ! 39: start rotate ! 40: start increment stop { ! 41: newpath ! 42: radius 0 moveto ! 43: -3 0 rlineto ! 44: closepath ! 45: stroke ! 46: increment neg rotate ! 47: } for ! 48: grestore ! 49: endps ! 50: ! 51: /* PSWdrawString simply draws string at specific location ! 52: */ ! 53: defineps PSWdrawString(float x; float y; char *str) ! 54: 0 setgray ! 55: x y moveto ! 56: (str) show ! 57: endps ! 58: ! 59: /* PSWmakeHand defines a PS function that will subsequently be used ! 60: * to draw the hand at different angles as the value changes. ! 61: */ ! 62: defineps PSWmakeHand(float length) ! 63: /mhand { ! 64: 0 setgray ! 65: 0 setlinewidth ! 66: newpath ! 67: 0 3.5 moveto ! 68: 0 0 3.5 90 270 arc ! 69: length 3.5 rlineto ! 70: length neg 3.5 rlineto ! 71: closepath ! 72: fill ! 73: newpath ! 74: 0 2 moveto ! 75: 0 0 1.5 0 360 arc ! 76: closepath ! 77: 1 setgray ! 78: closepath ! 79: fill ! 80: } def ! 81: endps ! 82: ! 83: /* PSWdrawHand translate and rotates the coordinate system, then uses ! 84: * mhand to draw the gauge hand. ! 85: */ ! 86: ! 87: defineps PSWdrawHand(float x; float y; float ang) ! 88: gsave ! 89: x y translate ! 90: ang rotate ! 91: mhand ! 92: grestore ! 93: endps
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.