在 iPhone 上以增加的线宽绘制线条

发布于 2024-12-12 07:23:32 字数 140 浏览 0 评论 0原文

我在 iOS 上通过在 CALayer 上画一条路径来画一条线。如何用不断增加的 lineWidth(描边宽度)来描画这条线,使线的左端比右端细? (它确实必须是一条线,而不是形状或闭合路径,因为我将使用 strokeEnd 属性。)

感谢您的帮助!

I'm drawing a line on iOS by stroking a path onto a CALayer. How can I stroke this line with an increasing lineWidth (stroke width), so that the left end of the line is thinner than the right end? (It really has to be a line, not a shape or closed path, since I'm going to be using the strokeEnd property.)

Thank you for your help!

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

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

发布评论

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

评论(1

凤舞天涯 2024-12-19 07:23:32

使用绘图功能。一开始习惯起来很烦人,但它确实起到了作用。如果您需要更多帮助,请发表评论

-(void)draw{
     float lineHeight = 5;//change this as you see fit, like set it equal to an incrementing/decrementing variable of your choice...
     glEnable(GL_LINE_SMOOTH);
     glLineWidth(lineHeight); // change this as you see fit
     glColor4ub(255,255,255,255); // change these as you see fit :)
     ccDrawLine(ccp(10,310), ccp(30,310));  // these numbers are probably off, you'll   have to mess with these to get it in the right position :)
        [super draw];
        }

Use a draw function. It's pretty annoying to get used to at first, but it does its job. If you need anymore help just leave comment

-(void)draw{
     float lineHeight = 5;//change this as you see fit, like set it equal to an incrementing/decrementing variable of your choice...
     glEnable(GL_LINE_SMOOTH);
     glLineWidth(lineHeight); // change this as you see fit
     glColor4ub(255,255,255,255); // change these as you see fit :)
     ccDrawLine(ccp(10,310), ccp(30,310));  // these numbers are probably off, you'll   have to mess with these to get it in the right position :)
        [super draw];
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文