开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜