Technology recommendations for animation/display
Technology recommendations for animation/display
- Subject: Technology recommendations for animation/display
- From: Kenneth Baxter <email@hidden>
- Date: Sat, 24 Mar 2012 07:02:31 +0000 (GMT)
Hi, I am developing an application where I need to be able to handle the following requirements:
- Deployment: MacOS X 10.6 and later. May want to develop an iPad version later.
- Type of application: Display and manipulation of graphical objects on a canvas.
- Number of graphical objects: up to about 2,000
- Canvas needs to display solid color, gradient, or tiled image
- The entire canvas with all the graphical objects on it need to be able to smoothly zoom and pan
- Many of the graphical objects need to display text on them this must be high resolution rendering to look good
- The text on graphical objects needs to be editable (I'm ok with putting a view overlay over it in order to accomplish this if necessary)
- The graphical objects need to be able to be displayed with shadows and reflections.
- The entire canvas and all the displayed objects must be printable at high resolution (i.e. PDF).
- We need to animate movement of quite a number of the objects at once.
- The objects that are moving have curved connection lines drawn to other objects that stay stationary, and those curves need to animate as the connected objects move.
I am looking for recommendations on the best technology to use for this.
The following are my thoughts so far, based on trying a few things:
1. Using an NSView and just drawing on that, I can get scaling and printing for free, but I can't use subviews for each of the graphical objects because you can't set the z order of sibling subviews, so I would have to create my own layer system which just draws to the view that I am using - easy enough, and I've done that before. But of course with this system, I miss out on all the benefits of core animation, and have to create my own custom animation code (presumably with NSAnimation), and it's all just standard view drawing, which I presume isn't making use of much by way of GPU acceleration etc.
2. Using CALayers at initial sight may appear to be the obvious thing for something graphical like this, but I have observed a number of issues with it. For my background, using tiled layers seems to not work too well when you have large texture images being tiled, and you can see the tiles being drawn. Scaling seems to be an issue as everything gets scaled and then redrawn, and looks blurry in the middle, and I have to take the scale factor into account with every piece of drawing code, including scaling fonts and even inline images in text etc. Also, printing is a problem, though I have found some code that goes through and extracts CG drawing commands and sends them to a PDF context, which gets me most of the way there, except that it seems to have trouble with translucent colors in some circumstances (especially on gradients), and can't draw shadows. I can't add a subview for the text editing, so have to create an overlay invisible window and position it right, and pass on scroll and zoom events etc just to have an editable subview that I can use for text editing. Also, I've come across some issues where a graphical object is over 10,000 pixels in one dimension in certain circumstances and on older computers in particular, the entire graphics buffer seems to get screwed up, and it flickers while it redraws (and the redraw is slow). Apple have acknowledged this issue, and it may well have already been fixed in 10.7+, but is IMHO very unlikely to be fixed in 10.6, so I'd have to find a workaround for that. Also, no matter what I do, the text drawing seems to never be as crisp as it is when I draw straight on my view in the NSView case. And despite having CAShapeLayer now, it sometimes seems to draw my curves doing crazy things during animations. So quite a lot of debugging to do.
So should I go with NSView based drawing, where I know that the drawing and printing is going to work just right, and I have to code my own animations for zooming, scrolling, and moving objects around? Would I be able to get good enough performance doing this to get smooth animations? Are there any other downsides to this?
Or should I go with Core Animation, and sort out the issues with drawing the tiled background, zooming smoothly, printing with shadows, text quality, having to have overlay windows, drawing everything scaled, etc, in order to be using the latest technologies and get the advantages of core animation?
Or is there some other or hybrid option that I am not thinking of?
Which approach would be easiest to port later to iPad?
Any advice on this would be great!
Thanks, Ken.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden