I want to stroke a CGContext path with three or four images, but randomly scan the images as I draw the path. I want to draw INSTEAD images !! from the CGContext picture I am now. I have this code so far
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint currentPoint = [touch locationInView:self.view]; currentPoint.x = currentPoint.x; currentPoint.y = currentPoint.y; mouseSwiped = YES; UIGraphicsBeginImageContext(self.view.frame.size); [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; CGContextSetShouldAntialias(UIGraphicsGetCurrentContext(), YES); CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), brushSizeVal); CGContextSetAlpha(UIGraphicsGetCurrentContext(), drawingColorAlpha); CGContextSaveGState(UIGraphicsGetCurrentContext());
and
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { if (!optionsDisplayerVisible && canDraw) { if(!mouseSwiped) { UIGraphicsBeginImageContext(self.view.frame.size); [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; CGContextSetShouldAntialias(UIGraphicsGetCurrentContext(), YES); CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), brushSizeVal); CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), drawingColorRed, drawingColorGreen, drawingColorBlue, drawingColorAlpha); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); CGContextStrokePath(UIGraphicsGetCurrentContext()); CGContextFlush(UIGraphicsGetCurrentContext()); drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
source share