Ich möchte eine Funktion wie ein Pinsel erfüllen. Der Bereich, in dem sich der Finger wischt, ändert sich mit der allmählich geänderten Grenze. Folgend CodesWie kann ich mit CoreGraphics eine Linie zeichnen, die sich allmählich ändert?
Ich kann nur die Farbe Kristall mit klarer jetzt ändern:
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
if(self.eraser) return;
CGFloat scale = self.transform.a;
if (scale < 1) scale = 1;
CGPoint p = [[touches anyObject] locationInView: self];
CGPoint q = [[touches anyObject] previousLocationInView: self];
UIImage* image;
image = self.image;
CGSize size = self.frame.size;
UIGraphicsBeginImageContext(size);
CGRect rect;
rect.origin = CGPointZero;
rect.size = size;
[image drawInRect:rect];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineCap(context, kCGLineCapRound);
CGContextBeginPath(context);
CGContextSaveGState(context);
CGContextSetLineWidth(context, (10.0/scale) + 1);
CGContextSetBlendMode(context, kCGBlendModeClear);
CGContextMoveToPoint(context, q.x, q.y);
CGContextAddLineToPoint(context, p.x, p.y);
CGContextStrokePath(context);
CGContextRestoreGState(context);
UIImage* editedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[self setBounds:rect];
[self setImage:editedImage];
}
Wie kann ich die Kante mit allmählich ändern bekommen? Danke im Voraus.