From: Duncan M. <du...@on...> - 2009-07-08 08:54:02
|
On 7 Jul 2009, at 15:20, Scott Thompson wrote: > Great! Now that you've got that sorted out, and at the risk of > being booted off the __ruby__cocoa list, let me offer a suggestion > that may help. > > Rubycocoa is a very nice tool, but if you want to interact with > Quartz 2D from a scripting environment, I might suggest using Python > if you can stomach the language. Apple provides direct and > integrated support for Quartz 2D from Python through a dedicated and > supported API. See, for example: > > http://developer.apple.com/graphicsimaging/pythonandquartz.html > > and > > http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_python/dq_python.html > > It makes me sad :'-( that the same interface is not available > through Ruby but in this particular case, with lots of Quartz 2D > work to be done, if you can force yourself to learn "enough Python" > it may give you a better, more battle-tested interface. It doesn't sound like there's anyone else around to kick us out! I'm using RubyCocoa as glue inside VelOCRaptor, my Mac OCR app. The GUI is pure ObjC, but all the interfacing to the OCR engine is done by shelling to a Ruby command-line app that reads the input files and writes the output PDF. Ruby was a fantastic choice for parsing the OCR output and gluing it all together, and as I started talking to Cocoa to read PDFs, convert image formats, and write PDF files, RubyCocoa made sense. I had seen the Python Quartz interface, and I've nothing against Python, but as I start from Ruby it would mean another thunking, and frankly I'm only using the CGImage stuff because I can't get NSGraphicsContext graphicsContextWithGraphicsPort:flipped: working in order to use NSImage drawInRect: I'm afraid that given my problems calling some methods at all and other problems with memory leaks that I just don't seem to be able to plug (I need to loop over hundreds of 300 DPI A4 images) I am retreating back into loading native ObjC from a code bundle for those critical bits. I can see that MacRuby is getting the traction at the moment, and it is probably a better way to go, but as a recently released commercial product with a bug to fix the path of least resistance right now is moving code into ObjC, as at least that way I can ask for mainstream support (present company excepted). As the author of the Rococoa Java/Cocoa bridge I know how hard this stuff is to get right, and that there are some memory management issues that Apple just don't give us the tools to solve. Perhaps RubyCocoa just can't meet the brief. Cheers Duncan |