views:

172

answers:

1

Hello Everybody !

This code i use to draw in my app. So i have problem, if i draw with alpha property = 1. It is very good but if i change alpha property = 0.2 then my paint is not good. How do i make for better with alpha property = 0.2.

http://www.flickr.com/photos/9601621@N05/page1/

Draw with alpha = 1: It is good Draw with alpha = 0.2: It is bad

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

if ([self.view superview] && (headerView.frame.origin.y == -30)) { mouseSwiped = YES;

UITouch *touch = [touches anyObject]; CGPoint currentPoint = [touch locationInView:self.view]; currentPoint.y -= 20;

UIGraphicsBeginImageContext(self.view.frame.size);

CGContextRef context = UIGraphicsGetCurrentContext();

[drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; CGContextSetLineCap(context, kCGLineCapRound); CGContextSetLineWidth(context, currentBrushProperty.brushSize); CGContextSetRGBStrokeColor(context, [self red], [self green], [self blue], currentBrushProperty.brushTransparency); CGContextSetRGBStrokeColor(context, 1.0, 0.0, 0.0, 1.0);

CGContextBeginPath(context); CGContextMoveToPoint(context, lastPoint.x, lastPoint.y); CGContextAddLineToPoint(context, currentPoint.x, currentPoint.y);

CGContextStrokePath(context); drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();

lastPoint = currentPoint;

}}

Help me, please.

A: 

Your problem is that you are drawing a series of semi-transparent circles - one for each place at which the touch is registered. The easiest solution might be to draw with 100% alpha then adjust the alpha of the coloured region back to the alpha you want.

Andiih