objective-c - 如何反转三角形切口 - OSX

时间:2013-10-09 13:10:11

标签: macos cocoa graphics nsbezierpath

我需要一些帮助来扭转三角形切口。

我可以在右边做一个带有三角形切口的矩形:

enter image description here

使用这些坐标:

NSInteger imageWidth=12, imageHeight=22;
NSImage* destImage = [[NSImage alloc] initWithSize:NSMakeSize(imageWidth,imageHeight)];
[destImage lockFocus];

// Constructing the path
NSBezierPath *leftTriangle = [NSBezierPath bezierPath];
[leftTriangle setLineWidth:1.0];
[leftTriangle moveToPoint:NSMakePoint(imageWidth+1, 0.0)];
[leftTriangle lineToPoint:NSMakePoint( 0, imageHeight/2.0)];
[leftTriangle lineToPoint:NSMakePoint( imageWidth+1, imageHeight)];
[leftTriangle closePath];
[[NSColor controlColor] setFill];
[[NSColor clearColor] setStroke];

...

我会用什么坐标在另一边制作切口,如下所示:

enter image description here

更新:不客气地解决了:

有助于记住测量从左下角开始。

NSBezierPath * rightTriangle = [NSBezierPath bezierPath]; [rightTriangle setLineWidth:1.0]; [rightTriangle moveToPoint:NSMakePoint(0.0,29)]; [rightTriangle lineToPoint:NSMakePoint(imageWidth,20)]; [rightTriangle lineToPoint:NSMakePoint(0.0,11)];

0 个答案:

没有答案