应用纹理来描边CGContextStrokePath [英] Applying a texture to stroke a CGContextStrokePath

查看:90
本文介绍了应用纹理来描边CGContextStrokePath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个简单的绘图程序。到目前为止,我能够使用给定的颜色描绘路径并且一切都很好。我想知道是否有办法用纹理而不是颜色来抚摸它。比方说,我想给路径看铅笔线。关于如何做到这一点的任何想法?

I am working on making a simple drawing program. So far I am able to stroke the path with a given color and that all works out fine. I was wondering if there was a way to stroke it with a texture instead of a color. Say for instance I want to give the path the look of a pencil line. Any idea on how I would go about doing that?

提前感谢您的帮助!

推荐答案


  1. 开始透明层

  2. 获取路​​径的边界。

  3. 使用任何非路径描边路径透明的颜色。

  4. 将混合模式设置为 source in

  5. 使用所需的纹理图案填充步骤2中的边界矩形。

  6. 结束透明层。

  1. Begin a transparency layer.
  2. Get the path's bounds.
  3. Stroke the path with any non-transparent color.
  4. Set the blend mode to source in.
  5. Fill the bounding rectangle from step 2 with the desired texture pattern.
  6. End the transparency layer.

这篇关于应用纹理来描边CGContextStrokePath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆