English 中文(简体)
Any differences between the way Bézier curves are interpreted by Cocoa and SVG?
原标题:

I m definetely new to any kind of graphics (maybe except taking photos :)) so please forgive if my explanation of problem I faced last night is not very precise and understable.

I m trying to generate code in Cocoa which would draw vectors on the base of SVG files. I ve translated SVG commands into calls of NSBezierPath methods but received graphics is not really good... The shape is similar to the basic one but there are some... distortions(?). It s probably neither an issue of antialiasing nor flatness value set on Cocoa side. I was suggested that the problem may result from different interpretation of control points of Bézier curves by Cocoa methods ang SVG - is that possible? Or what else may cause the problem?

最佳回答

SVG curve to command is control point, control point, end point.

Cocoa curveToPoint method takes end point, control point 1, control point 2

问题回答

@Peter Hosey

Sure. At this moment I supose that there is really difference in Cocoa and SVG interpretations. I tried to use basic SVG examples and result in Cocoa is different.

SVG version:

<path d="M 100 200 C 100,100 400,100 400,200 z"/> 

Cocoa version:

path = [[NSBezierPath alloc] init]; 
[path moveToPoint:NSMakePoint(100, 200)]; 
[path curveToPoint:NSMakePoint(100, 100) controlPoint1:NSMakePoint(400, 100) controlPoint2:NSMakePoint(400, 200)]; 
[path sePath]; 

Or it is my stupid mistake which I can t notice :)

// I m not using "Add comment" because of lack of code formatting.





相关问题
Taking picture with QTCaptureView

Is it possible to simply take a picture and save it somewhere using a QTCaptureView and Apple s built-in iSight? I ve seen lots of tutorials on recording video but none on simply taking a picture. Any ...

Controlling OSX windows

I m trying to control windows of a foreign OSX applications from my application. I d like to 1. move the windows on the screen 2. resize the windows on the screen 3. change the currently active window ...

objective-c: Calling a void function from another controller

i have a void, like -(void) doSomething in a specific controller. i can call it in this controller via [self doSomething], but i don t know how to call this void from another .m file. I want to call ...

NSUndoManager and runModalForWindow:

I have a simple Core Data app which displays a list of entities in the main window. To create or add new entities, I use a second modal window with a separate managed object context so changes can be ...

NSMutableArray values becoming "invalid"

I m trying to show a database information in a tableview and then the detailed information in a view my problem is as follow: I created a NSMutableArray: NSMutableArray *myArray = [[NSMutableArray ...

How to get a flash url in a webpage using a webframe?

As we know , When we load frame from webpage of safari, we will invoke the delegate methods of webkit informal protocol(WebFrameLoadDelegate): webView:didStartProvisionalLoadForFrame: webView:...

热门标签