相关疑难解决方法(0)

iPhone平滑的草图绘制算法

我正在开发iPhone上的草图应用程序.我得到了它的工作,但不是在这里看到的漂亮 在此输入图像描述

我正在寻找任何平滑绘图的建议基本上,我所做的是当用户将手指放在我调用的屏幕上时

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
Run Code Online (Sandbox Code Playgroud)

然后我收集一个阵列中的单个触摸

- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
Run Code Online (Sandbox Code Playgroud)

当用户从屏幕上拿出一根手指时,我打了个电话

- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
Run Code Online (Sandbox Code Playgroud)

然后我用数字绘制数组中的所有点

NSMutableArray *points = [collectedArray points];   

CGPoint firstPoint;
[[points objectAtIndex:0] getValue:&firstPoint];

CGContextMoveToPoint(context, firstPoint.x, firstPoint.y);
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineJoin(context, kCGLineJoinRound);

for (int i=1; i < [points count]; i++) {
    NSValue *value = [points objectAtIndex:i];
    CGPoint point;
    [value getValue:&point];    
    CGContextAddLineToPoint(context, point.x, point.y);

} 

CGContextStrokePath(context);
UIGraphicsPushContext(context);
Run Code Online (Sandbox Code Playgroud)

而现在我想改进绘图更像是"Sketch Book"App 在此输入图像描述

我认为与信号处理算法有关,要重新排列阵列中的所有点,但我不确定.任何帮助将非常感激.

提前谢谢:)

iphone drawing quartz-graphics ios

60
推荐指数
4
解决办法
4万
查看次数

平滑手绘曲线

我有一个允许用户绘制曲线的程序.但是这些曲线看起来并不好看 - 它们看起来摇摇晃晃,手绘.

所以我想要一种能够自动平滑它们的算法.我知道平滑过程中存在固有的模糊性,因此每次都不会是完美的,但是这些算法似乎确实存在于几个绘图包中并且它们工作得很好.

是否有类似这样的代码示例?C#会很完美,但我可以翻译其他语言.

c# bezier spline smoothing

25
推荐指数
2
解决办法
2万
查看次数

标签 统计

bezier ×1

c# ×1

drawing ×1

ios ×1

iphone ×1

quartz-graphics ×1

smoothing ×1

spline ×1