Some questions about cocoa graphics2D
Some questions about cocoa graphics2D
- Subject: Some questions about cocoa graphics2D
- From: Andrea Perego <email@hidden>
- Date: Mon, 19 Nov 2001 17:06:23 +0100
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 ?!?). This is not a practical issue
for me, since I might re-apply the techniques I've used with
Quickdraw on the venerable Mac II to simplify the path, but I'm
somehow disappointed, since it implies taking into account "a priori"
the actual resolution of the final device (e.g. when more channels
would end up on the same vertical column of pixels, a single vertical
line is drawn connecting the min and max value of those channels),
which seems antithetical to the PDF doctrine and nullifies the
advantage of a floating coordinate system.
2) When the cursor enters a histo view, it should be substituted by a
cross-hair centered at the cursor position and spreading out to the
view's canvas (explaining why would be beyond the scope of this
message). I found it very easy to achieve this goal, but for the fact
that the [<myHistoView> drawRect...] method is called every time the
cursor moves. Back in Quickdraw, I resorted to draw the cursor in
"xor" mode, so that tracking the movement simply implied re-drawing
on the "old" position to clear the cross-hair and drawing the new one.
I've browsed thru the Cocoa docs, but I didn't find such a facility,
at least for "vector" graphics (please don't get angry with me if I'm
wrong! I wouldn't mind spending a couple of lines of e-mail to point
a fellow developer to some info if
it might spare her/him some hours of searching).
TIA
Andrea Perego
Univ. of Florence - Phys. Dept.