Note that there are some explanatory texts on larger screens.

plurals
  1. PODrawing straight lines when touched moved IOS
    primarykey
    data
    text
    <p>I have planned to do simple drawing up, using that use can draw straight lines and free hand drawing, based on the selection it change. But the problem is straight line gets repeated from the starting point more than 10 or 15 lines when i try to draw 1 line, free hand drawing working fine.I have posted my code here. Please give your suggestions to fix this issue. </p> <pre><code>- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { mouseSwiped = NO; UITouch *touch = [touches anyObject]; previousPoint1 = [touch previousLocationInView:self.view]; previousPoint2 = [touch previousLocationInView:self.view]; currentPoint = [touch locationInView:self.view]; lastPoint = [touch locationInView:self.view]; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { // Work download Flag _isWorkModified = YES; mouseSwiped = YES; UITouch *touch = [touches anyObject]; previousPoint2 = previousPoint1; previousPoint1 = [touch previousLocationInView:self.view]; currentPoint = [touch locationInView:self.view]; UIGraphicsBeginImageContext(self.view.frame.size); CGContextRef context = UIGraphicsGetCurrentContext(); [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; if(_selectedShape == 3) { // calculate mid point CGPoint mid1 = [self midPoint:previousPoint1 :previousPoint2]; CGPoint mid2 = [self midPoint:currentPoint :previousPoint1]; CGContextMoveToPoint(context, mid1.x, mid1.y); CGContextAddQuadCurveToPoint(context, previousPoint1.x, previousPoint1.y, mid2.x, mid2.y); CGContextSetLineCap(context, kCGLineCapRound); if(self.isEraseButtonSelected) { CGContextSetLineWidth(context, 40.0); CGContextSetRGBStrokeColor(context, 0.823,0.886,0.898,1.0); } else { CGContextSetLineWidth(context, 3.0); CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 1.0); } CGContextStrokePath(context); } else if(_selectedShape == 0) { CGContextSetLineWidth(context, 3.0); CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 1.0); CGContextBeginPath(context); CGContextMoveToPoint(context, lastPoint.x, lastPoint.y); CGContextAddLineToPoint(context, currentPoint.x, currentPoint.y); CGContextClosePath(context); CGContextStrokePath(context); } drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"touch ended"); if(!mouseSwiped) { NSInteger index = [[[AnswerDataHandler getAnswerDataHandler]workAreaArray] indexOfObject:self]; [[ImageStoreHelper getImageStoreHelper] saveImageForQuestionNumber:index image:drawImage.image]; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload