views:

213

answers:

2

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?

A: 

@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.

dzolanta
You should integrate this into your question.
Peter Hosey
+4  A: 

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

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

Pete Kirkham
That's it! Thank you, Pete.
dzolanta