v_white@pslu1.psl.wisc.edu (Victor White) (02/19/91)
I have been wrestling with the problem of doing graphics on a next. I was wondering if there any simple way to do graphics, without going through writing my own post-script macros?? In X-Windows I have used the VPLOT macros, which actually make X-window graphics "somewhat easy". In perticular, is there any relatively simple way to open up a window, and use functions on the order of "plotpoint x,y ", "drawline x1,y1,x2,y2", "circle x,y,r", etc.?? I searched through the on line documentation, and did not see much that would help. Any ideas would be appreciated. Victor White v_white@pslu1.psl.wisc.edu v_white@xraylith.wisc.edu
gessel@ilium.cs.swarthmore.edu (Daniel Mark Gessel) (02/21/91)
Plotting a single pixel seems to be a pain. I usually use a rectfill, but that seems horribly inneficient (anyone have a better way?). Use PSmoveto(x1,y1); PSlineto(x2,y2); PSstroke(); to draw a line. You may want to use PSsetgray(graylevel); and PSsetlinewidth(width); PSrectfill(x1,y1,x2,y2); is also nice. These are calls to PSwrapped code, so it's still basically postscript. PostScript is the way to go, it's also extremely easy to use with PSwrap and IB. Takes about a half an hour to get started, and improves your applications efficiency. It's also great to use YAP to develop your graphics! Knowing PostScript is pretty much a necessity when programming the NeXT. Dan -- Daniel Mark Gessel Internet: gessel@cs.swarthmore.edu I do not speak (nor type) representing Swarthmore College.
scott@erick.gac.edu (Scott Hess) (02/22/91)
In article <GESSEL.91Feb20144301@ilium.cs.swarthmore.edu> gessel@ilium.cs.swarthmore.edu (Daniel Mark Gessel) writes:
Plotting a single pixel seems to be a pain. I usually use a rectfill,
but that seems horribly inneficient (anyone have a better way?).
NXRectFill is very fast for single pixel plots. I just did some testing,
and found that if you draw a bunch of pixels, and then stroke them
all at once, NXRectFill and PSmoveto( x, y)/PSrlineto( .5, .5)
are about equivilant. Doing a stroke on every moveto/rlineto
pair makes that method _much_ slower.
Of course, using NXRectFillList is even faster, especially for large
sets of pixels. I tested once drawing 4096 pixels, and again with
16k pixels. The results (in seconds) were:
4K 16K
PS-wrap 6 24
NXRectFill 6 28
NXRectFillList 2 5
Of course, those are all of the same color, etc. You might ask why
I did such a thing - boredom.
Use PSmoveto(x1,y1); PSlineto(x2,y2); PSstroke(); to draw a line.
You may want to use PSsetgray(graylevel); and PSsetlinewidth(width);
PSrectfill(x1,y1,x2,y2); is also nice. These are calls to PSwrapped
code, so it's still basically postscript.
If you are able to limit line drawing to vertical and horizontal
lines, NXRectFill and NXRectFillList are big winners, again.
With both line and pixel drawing, the main goal is to minimize the
data traffic moreso than the actual drawing time. A couple runs
through the output of -NXShowPS applied to your app gives a good
idea of where you're going wrong (an extra setgray per pixel will
really slow things down . . .)
PostScript is the way to go, it's also extremely easy to use with
PSwrap and IB. Takes about a half an hour to get started, and improves
your applications efficiency. It's also great to use YAP to develop
your graphics! Knowing PostScript is pretty much a necessity when
programming the NeXT.
Hey, don't forget the most important part - it's darn fun to play
with Postscript . . .
Later,
--
scott hess scott@gac.edu
Independent NeXT Developer GAC Undergrad
<I still speak for nobody>
"Tried anarchy, once. Found it had too many constraints . . ."
"Buy `Sweat 'n wit '2 Live Crew'`, a new weight loss program by
Richard Simmons . . ."