0

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

我可以制作右侧带有三角形切口的矩形:

在此处输入图像描述

使用这些坐标:

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)];

4

0 回答 0