Re: Some questions about cocoa graphics2D
Re: Some questions about cocoa graphics2D
- Subject: Re: Some questions about cocoa graphics2D
- From: email@hidden
- Date: Wed, 21 Nov 2001 21:40:22 +0100
On Monday, November 19, 2001, at 08:06 AM, Andrea Perego wrote:
Hi!
I'm doing preliminary experiments to port a "classic" application to
Cocoa, and I could use some help & advice from more experienced
developers.
1) The purpose of my app is manipulating spectra, that are drawn in
form of histograms. My first idea was just to draw them as a single
bezier path (up to 4k or 8k channels = 8k or 16k lines), letting the
rendering engine take care of
actual rasterization and display. What I found out is that
[<myBezierPath> stroke] for such a path may be a very slow operation:
it takes about 2 seconds to stroke 8k lines on my G4-733 at work, while
the same operation on a 400Mhz iMac took about 15 seconds (does
"stroke" exploit altivec on G4 ?!?).
NSBezierPath falls apart when you have a whole lot of segments,
particularly if they intersect each other. In fact, I'm rather
surprised that a path with 8K segments didn't lock up the app altogether.
I've been plotting image histograms myself lately, but with far fewer
columns than your spectrograms.
I'd suggest doing your own data reduction, and then drawing the
histogram with NSRectFillListWithColors(), or one of the other
NSRectFill... functions.
-jcr
Another way you can consider is using OpenGL. It is quite easy to handle,
particularly in 2D, and VERY FAST. In Cocoa you just have to add the
frameworks to your app, put an NSOpenGLView in the window, and issue
openGL calls in the drawRect method. There are somme good examples on the
Web.
Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.