UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.colorView];
//currentPoint.y -= 20;
if (appDelegate.iphoneIpad==1) {
drawPencil.frame=CGRectMake(currentPoint.x+5,currentPoint.y-30,drawPencil.frame.size.width,drawPencil.frame.size.height);
}
else{
drawPencil.frame=CGRectMake(currentPoint.x+10,currentPoint.y-80,drawPencil.frame.size.width,drawPencil.frame.size.height);
}
if (eraseDrawImg==NO) {
//For Drawing of line....
//drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsBeginImageContext(self.colorView.frame.size);
[drawImage.image drawInRect:CGRectMake(0, 0, drawImage.frame.size.width, drawImage.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), eraseSize);
CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(),color);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
drawImage.image=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
else{
//For Erasing of Drawn line....
UIGraphicsBeginImageContext(self.colorView.frame.size);
[drawImage.image drawInRect:CGRectMake(0, 0, drawImage.frame.size.width, drawImage.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(),kCGImageAlphaNone); //kCGImageAlphaPremultipliedLast);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), eraseSize);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1, 0, 0, 10);
CGContextAddArc(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y, eraseSize, 0.0, 2*M_PI, 0);//, 50, 50, 50, 0.0, 2*M_PI, 0);
CGContextClip(UIGraphicsGetCurrentContext());
CGContextClearRect(UIGraphicsGetCurrentContext(),self.colorView.frame);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextClearRect(UIGraphicsGetCurrentContext(), CGRectMake(lastPoint.x, lastPoint.y, eraseSize,eraseSize));
CGContextStrokePath(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
// NSLog(@"%d",imageTag);
NSLog(@"%@",lineArray);
lastPoint = currentPoint;
mouseMoved++;
if (mouseMoved == 10) {
mouseMoved = 0;
}
}