以编程方式绘制一条粗略的线条 [英] Drawing a sketchy-looking line, programmatically

查看:138
本文介绍了以编程方式绘制一条粗略的线条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道你们是否知道如何在iOS应用程序上绘制一条粗略的线条。
目前我正在绘制感谢一个UIBezierPath,然后我渲染成一个位图图形上下文。

I would like to know if you guys have any idea of how I could possibly draw a sketchy-looking line on an iOS app. Currently I am drawing thanks to a UIBezierPath which I then render into a bitmap graphics context. How could I make the line look sketchy?

// Produce and add points to draw in the UIBezierPath

// Draw the path into the Bitmap context

UIGraphicsBeginImageContext(self.bounds.size);  
        [frameBuffer drawAtPoint:CGPointMake(0, 0) blendMode:kCGBlendModeCopy alpha:1.0];
        [[datasource lineStrokeColorForSketchCanvas:self] setStroke];
        [curvePath stroke];    
image = UIGraphicsGetImageFromCurrentImageContext();    
    UIGraphicsEndImageContext();

非常感谢ou)

推荐答案

我建议使用一小批粗略线纹理,然后使用这些+ UIBezierPath将正确旋转的路径上的粗略图像放置。

I would suggest using a small batch of "sketchy" line textures, and then using those + the UIBezierPath to place the sketchy images along the path at the correct rotation.

您可以将这些内容绘制到上下文中,并保存它们,以便您不必每次都生成它们。

You could draw those to the context, and save them so that you don't have to generate them every single time.

详细说明:

从UIBezierPath的一端开始,每隔x点指向路径,以该点为中心的直线段,继续直到到达路径的终点。

Start at one end of your UIBezierPath, every x points down the path, draw a sketchy line section centered on that point, keep going until you get to the end of the path.

这篇关于以编程方式绘制一条粗略的线条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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