2010-05-14 1 views
0

Ce code est utilisé pour dessiner dans mon application. Donc j'ai un problème, si je dessine avec la propriété alpha = 1. C'est très bien mais si je change la propriété alpha = 0.2 alors ma peinture n'est pas bonne. Comment puis-je faire pour mieux avec la propriété alpha = 0.2.Problème lors du dessin de ligne par Quartz 2D avec la propriété alpha <1.0 sur l'iPhone

http://www.flickr.com/photos/[email protected]/page1/

Dessiner avec alpha = 1: Il est bon Dessiner avec alpha = 0,2: Il est mauvais

- (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; 

}} 

Répondre

0

Votre problème est que vous dessinez une série de cercles semi-transparents - un pour chaque endroit où le contact est enregistré. La solution la plus simple consisterait à dessiner avec 100% d'alpha puis à ajuster l'alpha de la région colorée à l'alpha que vous voulez.

Questions connexes