小编San*_*gar的帖子

如何在客观c中平滑地绘制自由手线?

我使用uigraphics cgcontext在触摸上绘制线条...但我的线条不平滑我的意思是边缘不光滑所以任何人都可以建议我如何画出流畅的线条.这里是我用来画线的代码:

/* touchesBegan */
UITouch *touch = [touches anyObject];
lastPoint = [touch locationInView:imagevw];

/* touchesMoved */

CGFloat width = [mySlider value];
UIGraphicsBeginImageContext(imagevw.frame.size);
[imagevw.image drawInRect:CGRectMake(0, 0, imagevw.frame.size.width,imagevw.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), width);
UITouch *touch = [touches anyObject];
mouseSwiped = YES;  
    CGPoint currentPoint = [touch locationInView:imagevw];
    CGContextBeginPath(UIGraphicsGetCurrentContext());
    CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
    CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
    CGContextStrokePath(UIGraphicsGetCurrentContext());
    imagevw.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
lastPoint = currentPoint;





/*  touchesEnded */
/* same here */ 
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
        CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);`
Run Code Online (Sandbox Code Playgroud)

这是我的代码,我可以画线自由,但它不是那么平滑显示像素我的意思是边缘不平滑

objective-c

3
推荐指数
1
解决办法
4836
查看次数

如何获取DisplayObject的颜色(填充)以响应Corona SDK中的触摸等事件?

任何人都可以帮我找出如何在日冕中获得矩形的颜色?那个矩形我已经填充了颜色,所以现在我想在触摸矩形时获得那种颜色.

coronasdk

3
推荐指数
1
解决办法
3393
查看次数

标签 统计

coronasdk ×1

objective-c ×1