开发者社区> 问答> 正文

CoreGraphics画线时模糊的问题

我看CoreGraphics的教程时,里面提到1像素绘图模糊的问题,需要偏移0.5点才行。这是为什么呢?stroke path不是stroke在边界上吗?

It turns out that when Core Graphics strokes a path, it draws the stroke on the middle of the exact edge of the path.
这句话要怎么理解呢?

展开
收起
a123456678 2016-07-20 15:23:44 2296 0
1 条回答
写回答
取消 提交回答
  • 在Xcode搜索CGContextSetLineWidth的文档,上面有提到:

    The default line width is 1 unit. When stroked, the line straddles the path, with half of the total width on either side.
    就是说如果设置宽度为1个像素的线,那么绘制线条分别在所绘路径的两边,每边各一半宽度,即0.5像素。而正在在屏幕上绘制时,是以像素为单位绘制的,并且对于显示内容不满一个像素时,为了平滑显示内容默认使用了抗锯齿效果。如下面中间图形所示,对于1个像素宽度蓝色的线条,左右个0.5像素,剩下0.5像素使用抗锯齿,用淡蓝色绘制。
    screenshot

    2019-07-17 19:58:56
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载