gpt4 book ai didi

macos - quartz 线插值在某些线宽下变得不稳定

转载 作者:行者123 更新时间:2023-12-03 17:11:52 24 4
gpt4 key购买 nike

我一直在使用以下代码在我的基本绘画应用程序中绘制用户输入:

CGContextRef drawSpace = CGLayerGetContext(currentLayer);

CGContextBeginPath(drawSpace);

CGContextMoveToPoint(drawSpace, [[self.currentStroke objectAtIndex:0]pointValue].x, [[self.currentStroke objectAtIndex:0]pointValue].y);

for (NSValue *v in self.currentStroke) {
CGContextAddLineToPoint(drawSpace, [v pointValue].x ,[v pointValue].y);
/* CGContextMoveToPoint(drawSpace, [v pointValue].x ,[v pointValue].y);
The link I got only showed this called when index = 0, so I dummied it out. Left in,
it produces the original jagged image behavior */
}


CGContextClosePath(drawSpace);
CGContextSetStrokeColorWithColor(drawSpace, [[NSColor blackColor]CGColor]);
CGContextSetLineWidth(drawSpace, self.BrushSize); //Sets the brush size
CGContextStrokePath(drawSpace); //Strokes the path to the layer

这在小线宽下效果很好,但在大尺寸下,图像如下图所示。我知道这与角度有关,但我不知道如何纠正这个问题。有谁知道如何才能在任何尺寸下获得干净的笔画?

My drawing

最佳答案

您在图像中看到的是 Core Graphics 逐条绘制单线段的结果。因此,当然不会绘制线角,并且在大笔宽度上它会这样显示。

您应该做的是仅在完成绘制所有线段后才绘制线条。在这种情况下,运行时将为您处理角落。

另请参阅this question有关如何实现的更多信息。

关于macos - quartz 线插值在某些线宽下变得不稳定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21787610/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com