PDA

View Full Version : draw and import SVG Objects in Cocoa




Chandhu
Feb 26, 2008, 08:37 PM
Hi,

I am very new to Mac and Cocoa. I want to draw and import SVG objects in my Cocoa (using Objective C) windows application. Can anyone help me how to do this ? (I am using XCode 2.5 in my Tiger and XCode 3 in Leopard. I want to draw and import SVG objects in a Canvas using Objective C). How this is possible ???? Please help me...

Thanks in advance........



robbieduncan
Feb 27, 2008, 02:25 AM
Cocoa has no built in support for SVG so you are going to have to do quite a lot of work to make this happen. The way I see it you have two options:

1) Use WebKit to render the SVG an use JavaScript/DOM to manipulate the SVG within the document

2) Use libsvg (http://librsvg.sourceforge.net/) to render the svg

Chandhu
Feb 27, 2008, 07:26 AM
HI,

Thanks for the reply.
How can i use librsvg in my Cocoa Application ????
Since i am very new to Cocoa, could you please help me with a detailed solution for this? I need to draw the SVG objects in the existing canvas (NSView) in my Cocoa windows application using Objective C ????

Thanks in advance.....:)

robbieduncan
Feb 27, 2008, 07:34 AM
How can i use librsvg in my Cocoa Application ????
Since i am very new to Cocoa, could you please help me with a detailed solution for this?

Basically this is not a beginners topic or even close, so the answer is no, I'm not going to write your code for you. I suggest you start doing a lot of research into into using standard Unix libraries in Cocoa as well as spending a lot of time reading the libsvg documentation: you will have to do work to get the output of this to render into an NSView: it's not like it's going to provide an NSImage.

If I were you I'd be using WebKit...

Sayer
Feb 27, 2008, 07:57 AM
You can embed a webview into an NSView. Theres a bunch of sample code if you installed the Xcode tools at: /Developer/Examples/WebKit

You can link a webview to your Cocoa app using JavaScript very easily to provide command/control of the SVG in the webkit view as well.

I'd also recommend WebKit since it is already built out, already has high performance and support for manipulating SVG.

Don't think of WebKit as a web browser aka Safari. WebKit is the rendering and network engine that Safari is built on top of.

Chandhu
Mar 3, 2008, 09:24 AM
Hi,

Can we consider any shape that uses path for drawing, as SVG object?

please refer the link shown below:
http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_paths/chapter_4_section_1.html#//apple_ref/doc/uid/TP30001066-CH211-TPXREF101

And if we use the core grapics of Cocoa, can we create SVG objects?

Please advice me....

Thanks in advance....

robbieduncan
Mar 3, 2008, 01:26 PM
Hi,

Can we consider any shape that uses path for drawing, as SVG object?

please refer the link shown below:
http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_paths/chapter_4_section_1.html#//apple_ref/doc/uid/TP30001066-CH211-TPXREF101

And if we use the core grapics of Cocoa, can we create SVG objects?

Please advice me....

Thanks in advance....

Basically no. You could, perhaps, write a massive amount of code to make this possible, but Cocoa does not represent paths as SVG or anything like it.