本文介绍了应用纹理来描边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?
提前感谢您的帮助!
推荐答案
- 开始。
- 使用任何非路径描边路径透明的颜色。
- 设置为。
- 使用所需的纹理图案填充步骤2中的边界矩形。
- 结束透明层。
- Begin a transparency layer.
- Get the path's bounds.
- Stroke the path with any non-transparent color.
- Set the blend mode to source in.
- Fill the bounding rectangle from step 2 with the desired texture pattern.
- End the transparency layer.
这篇关于应用纹理来描边CGContextStrokePath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!