Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to remove dots from lines while drawing paint brush in iphone?
    primarykey
    data
    text
    <p><img src="https://i.stack.imgur.com/BkreR.png" alt="enter image description here">I am using following code to create the paint brush in iphone.</p> <pre><code>@interface Canvas : UIImageView { CGPoint location; } @property CGPoint location; .m file @synthesize location; - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; self.location = [touch locationInView:self]; } - (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint currentLocation = [touch locationInView:self]; UIGraphicsBeginImageContext(self.frame.size); CGContextRef ctx = UIGraphicsGetCurrentContext(); //CGContextSetBlendMode(ctx, kCGBlendModeOverlay); [self.image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; CGContextSetLineCap(ctx, kCGLineCapRound); CGContextSetBlendMode(ctx, kCGBlendModeNormal); CGContextSetLineWidth(ctx, 5.0); CGContextSetRGBStrokeColor(ctx, 1.0, 0.0, 0.0, 1.0); //CGContextSetBlendMode(ctx, kCGBlendModeOverlay); CGContextBeginPath(ctx); CGContextMoveToPoint(ctx, location.x, location.y); CGContextAddLineToPoint(ctx, currentLocation.x, currentLocation.y); CGContextStrokePath(ctx); self.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); location = currentLocation; } - (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint currentLocation = [touch locationInView:self]; UIGraphicsBeginImageContext(self.frame.size); CGContextRef ctx = UIGraphicsGetCurrentContext(); // CGContextSetBlendMode(ctx, kCGBlendModeOverlay); [self.image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; CGContextSetBlendMode(ctx, kCGBlendModeNormal); CGContextSetLineCap(ctx, kCGLineCapRound); CGContextSetLineWidth(ctx, 5.0); CGContextSetRGBStrokeColor(ctx, 1.0, 0.0, 0.0, 1.0); CGContextBeginPath(ctx); CGContextMoveToPoint(ctx, location.x, location.y); CGContextAddLineToPoint(ctx, currentLocation.x, currentLocation.y); CGContextStrokePath(ctx); self.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); location = currentLocation; } </code></pre> <p>It's working but while drawing there are some dots after certain distance in line which is being drawn.i want to remove those dots and want smooth straight line.How can i achieve this?</p>
    singulars
    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.
    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