drawbot icon indicating copy to clipboard operation
drawbot copied to clipboard

CocoaContext

Open typemytype opened this issue 9 years ago • 7 comments

A cocoaContext that can draw in NSViews

typemytype avatar May 20 '16 16:05 typemytype

Is that a question or a statement? :)

justvanrossum avatar May 20 '16 16:05 justvanrossum

A reminder ;)

On Friday, 20 May 2016, Just van Rossum [email protected] wrote:

Is that a question or a statement? :)

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/typemytype/drawbot/issues/49#issuecomment-220647494

gr Frederik www.typemytype.com

typemytype avatar May 20 '16 16:05 typemytype

hi! the issue is still open, so... should I assume that it is not possible yet?

roberto-arista avatar Oct 18 '17 08:10 roberto-arista

Btw. DB's PDFContext should be almost capable of this: we just need it to supply an explicit CGContext via NSGraphicsContext.currentContext().CGContext(). The internal _pdfContext attribute should be renamed _cgContext. There's very little PDF-specific code there.

justvanrossum avatar Feb 19 '18 12:02 justvanrossum

yeah, I tried that, this is working, but the overhead of drawBot was to much to use this as drawing tool in drawRect_ of a NSView...

typemytype avatar Feb 19 '18 13:02 typemytype

But then the description of this issue is inadequate, because it only mentions "can" and not "can super fast" :)

justvanrossum avatar Feb 19 '18 14:02 justvanrossum

Funnily enough I tried to use this to directly draw into a CG bitmap context, and to save that to PNG. That turned out to be slower than to just use the existing DB method (build the PDF data, render that to an NSImage and save that as PNG).

justvanrossum avatar Feb 19 '18 14:02 justvanrossum