I am making a calligraphy application and would like to change my code below, so when the user finishes the brush stroke, the line narrows and smoothes out, like with a real calligraphy pen (flick effect). I understand that touchsEnded may be the best way to do this, however, I'm just wondering what the best way would be to programmatically make this click at the end of a move using CGRect or GraphicsContext in UIKit in Xcode for Objective C.
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { mouseSwiped = YES; UITouch *touch = [touches anyObject]; currentPoint = [touch locationInView:self.view]; UIGraphicsBeginImageContext(CGSizeMake(320, 568)); [drawImage.image drawInRect:CGRectMake(0, 0, 320, 568)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0); CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0, 0, 0, 1); CGContextBeginPath(UIGraphicsGetCurrentContext()); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y); CGContextStrokePath(UIGraphicsGetCurrentContext()); [drawImage setFrame:CGRectMake(0, 0, 320, 568)]; drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); lastPoint = currentPoint; } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
source share