作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在使用以下代码在我的基本绘画应用程序中绘制用户输入:
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
这在小线宽下效果很好,但在大尺寸下,图像如下图所示。我知道这与角度有关,但我不知道如何纠正这个问题。有谁知道如何才能在任何尺寸下获得干净的笔画?
最佳答案
您在图像中看到的是 Core Graphics 逐条绘制单线段的结果。因此,当然不会绘制线角,并且在大笔宽度上它会这样显示。
您应该做的是仅在完成绘制所有线段后才绘制线条。在这种情况下,运行时将为您处理角落。
另请参阅this question有关如何实现的更多信息。
关于macos - quartz 线插值在某些线宽下变得不稳定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21787610/
我是一名优秀的程序员,十分优秀!