开发者

Issue when drawing line by Quartz 2D with alpha property < 1.0 on iPhone

This code I use to draw in my app. So 开发者_Python百科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;

 }}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜