News for hackers. Stuff that matters.
Re:PaintCode - Vector Based Obj-C Graphics Code Generator by tptacek on Monday April 02, 2012 @03:01PM (#3789558)
I'm waiting for someone to tell me what's horribly wrong with this before I click the "Buy" button, but it's taking effort to resist the urge. This looks extremely excellent.
Re:PaintCode - Vector Based Obj-C Graphics Code Generator by thought_alarm on Monday April 02, 2012 @03:26PM (#3789654)
Core Graphics drawing is actually quite slow. On the Retina iPad, drawing is 4 times as slow and uses 4 times as much memory as the 1st gen iPad, and all the CPU cores in the world are not going to help you.

Having recently ripped out most of my -drawRect: methods, replacing them with custom rendered UIImages, I can attest to the significant performance gains that UIImage gives you. On the Retina iPad, I think it's pretty much mandatory.

With that in mind, I think most people are better off using a tool like this to produce PDF data rather than raw CG calls, and use generic code to render that PDF data to a UIImage. PDF data produced by Quartz is going to render exactly the same as raw CG calls.

It makes for easier project management, and much better performance.

Of course, if you don't need resolution independent graphics, just use png.

Re:PaintCode - Vector Based Obj-C Graphics Code Generator by Zev on Monday April 02, 2012 @04:03PM (#3789802)
Its not that Core Graphics is slow, just that CG doesn't guarantee that drawing will take place on the GPU. It turns out that CG typically prefers the CPU for its its drawing. In comparison, when you load images into a UIImageView, you know that the drawing will be done on the GPU, instead.

Quick question: How does UIImage's -drawInRect: and -drawAtPoint: differ?[1]

With that in mind, I think most people are better off using a tool like this to produce PDF data rather than raw CG calls, and use generic code to render that PDF data to a UIImage

The CGPDFPage* functions that Apple provides are document-oriented (remember: the D in PDF stands for "document"), and don't necessarily work well in all cases, either. A compromise could be to render your CG calls into a context that is then turned into a UIImage that gets cached and stuck into a UIImageView for display. This way, you can do your drawing in CG*, get GPU-backed rendering, and don't have to deal with clumsy PDFs to get images.

So, my advice? Click the "buy" button. Drawing in code is just another tool to have. No reason to avoid doing so, if the situation calls for it -- and the trick to any tool is knowing when to use it.

1. If you guessed that -drawInRect is CPU-backed and drawAtPoint: is GPU-backed, pat yourself on the back. Simply having your resources in a UIImage isn't enough to guarantee GPU-backed drawing. And drawing on the GPU isn't enough to guarantee that it will be fast.

Re:PaintCode - Vector Based Obj-C Graphics Code Generator by ryanpetrich on Monday April 02, 2012 @05:41PM (#3790226)
drawAtPoint: and drawInRect: both call through to drawInRect:blendMode:alpha: which calls through to CGContextDrawImage. CGContextDrawImage has some optimizations to handle unscaled blends and further optimizations for unscaled blits, but it doesn't use the GPU on iOS. Even if it did, it would be using the GPU to draw into a temporary buffer that would have to be drawn again when the QuartzCore scene is rendered.
Re:PaintCode - Vector Based Obj-C Graphics Code Generator by DHowett on Monday April 02, 2012 @03:12PM (#3789599)
The only real downsides I can find are that:

1) You need to design the selected/deselected states for buttons separately and merge the code.

2) It'll give you drawing code, but you have to maintain those chunks of code directly in your source files. Any modifications you make to the code need to be reflected in the original PaintCode data, and vice-versa. This could be solved with clever comment guards and the ability to rebuild internal structure from the code it generated.

Neither of these really detract from the product. I've only used the demo, but it's honestly pretty amazing.

Re:PaintCode - Vector Based Obj-C Graphics Code Generator by 286c8cb04bda on Monday April 02, 2012 @03:44PM (#3789727)
I've used it, and had no problems at all. It's missing a few features before I can whole-heartedly recommended it over Opacity[1], which is what I use for the same purpose right now. Right now I'd need to make separate on/off state, for example, for each button. Opacity's factories & variables make that much easier.

That said, Opacity's development has slowed to a crawl. If the gentleperson(s) behind PaintCode keep it up, they will surely surpass it very soon.

[1]: http://likethought.com/opacity/

Re:PaintCode - Vector Based Obj-C Graphics Code Generator by J3L2404 on Monday April 02, 2012 @03:08PM (#3789584)
There is a trial version so try away.
Re:PaintCode - Vector Based Obj-C Graphics Code Generator by tptacek on Monday April 02, 2012 @03:17PM (#3789617)
The money is irrelevant. $70 is chump change for any application I care about enough to do custom drawing in. But if there's something unworkable about the approach, I sure wouldn't want to waste my time.

(I have a couple Mac Cocoa apps I'm working on that I kinda sidelined because UI controls were painful).

Re:PaintCode - Vector Based Obj-C Graphics Code Generator by J3L2404 on Monday April 02, 2012 @03:26PM (#3789653)
I see. Well $70 isn't irrelevant for everyone so I am glad they have the free trial. Good luck on your apps!