我需要一些帮助来扭转三角形切口。
我可以在右边做一个带有三角形切口的矩形:
使用这些坐标:
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];
...
我会用什么坐标在另一边制作切口,如下所示:
更新:不客气地解决了:
有助于记住测量从左下角开始。
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)];