CoreGraphics 圆角厚度

发布于 2024-08-26 03:19:40 字数 281 浏览 4 评论 0原文

每当我在 iPhone 上描画带有圆角的路径时,圆角都会比描画路径的其余部分更粗。请参阅此处了解我的意思:

圆角厚度 http://img181.imageshack.us/ img181/6372/screenshot20100320at123.png

不知道为什么会发生这种情况,有什么想法吗?

Whenever I stroke a path with rounded corners on iPhone, the rounded corners are thicker than the rest of the stroked path. See here for what I mean:

rounded corner thickness http://img181.imageshack.us/img181/6372/screenshot20100320at123.png

Not sure why this happens, any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

谢绝鈎搭 2024-09-02 03:19:40

我同意 Peter Hosey 的分析,即线条的外半部分被剪掉,但我的建议是将所有坐标向内移动 0.5 像素。这样,您的直线也会更加清晰(不会在 2 个屏幕像素上进行抗锯齿处理)。

I agree with Peter Hosey's analysis that the outer half of your lines is getting clipped off, but my recommendation would be to move all the coordinates .5 pixels inward instead. This way your straight lines will be crisper (not antialiased across 2 screen pixels) as well.

罗罗贝儿 2024-09-02 03:19:40

我怀疑你是在矩形剪切路径内绘制的;角完全落在矩形内,但边被切成两半:一半在剪切路径内,因此被绘制,一半在外部,因此被剪切掉。

在抚摸它之前尝试将路径添加到剪切路径。

为此,您需要将 CGPath 添加到上下文的当前路径两次:

  1. 将 CGPath 添加到当前路径。
  2. 将当前路径添加到剪切路径(从而清空当前路径)。
  3. 将 CGPath 添加到当前路径。
  4. 行程电流路径。

I suspect that you're drawing within a rectangular clipping path; the corners fall completely within the rectangle, but the sides get cut in half: half inside the clipping path and so drawn, half outside and so clipped out.

Try adding the path to the clipping path before stroking it.

To do this, you will need to add the CGPath to the context's current path twice:

  1. Add CGPath to current path.
  2. Add current path to clipping path (thereby emptying current path).
  3. Add CGPath to current path.
  4. Stroke current path.
触ぅ动初心 2024-09-02 03:19:40

只是看起来比较厚而已。如果放大它,您会发现看起来像几个额外的黑色像素实际上是由抗锯齿引起的一些灰色像素。

尝试关闭抗锯齿功能,看看结果是否看起来更好。

编辑:右下角似乎也有阴影效果。

It just looks thicker. If you zoom in on it you will see what looks like a couple extra pixels of black is actually some pixels of gray caused by antialiasing.

Try turning off antialiasing to see if the result looks better.

Edit: Also the bottom right corner seems to have a drop shadow effect.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文