나는 초심자 아이폰에 페인트 응용 프로그램을 작업입니다.UIImageView에서 에어 브러시를 그리는 방법은 무엇입니까?
앱은 에어 브러쉬라는 내 아이폰 ... UIImageView에 살포합니다
을위한 새로운 도구를 추가. 어느 누구도 그걸로 일하는 법을 도와 줄 수 없어요.
나는 초심자 아이폰에 페인트 응용 프로그램을 작업입니다.UIImageView에서 에어 브러시를 그리는 방법은 무엇입니까?
앱은 에어 브러쉬라는 내 아이폰 ... UIImageView에 살포합니다
을위한 새로운 도구를 추가. 어느 누구도 그걸로 일하는 법을 도와 줄 수 없어요.
CGContextBeginPath
및 관련 기능을 찾고 계신 것 같습니다. 나는 새로운 뇌졸중을 정의하는 방법을 잘 모르지만, [UIColor colorFromImage:myImage]
과 같은 것으로 처리 될 수 있다고 상상한다. Quartz 2D를 살펴보고 here을 찾아보십시오.
/토마스
감사합니다 토마스 ..... 초크처럼 선을 그릴 수있는 방법이 있습니까? – kiran
공원에서 산책하지 않을 것입니다. Quartz 2D API를 사용하여 사용자 정의 펜 (획)을 만들 수 있어야합니다. API에서이 기능을 찾을 수 없다면 가장 좋은 추측은 사용자가 이미지를 터치 할 때 이미지를로드하고 (분필로 흰색을 반올림하여) 지속적으로 이미지에 페인트 할 수 있다는 것입니다. UIResponder에서'touchesBegan : withEvent :'를 사용해야하거나 Gesture Recognizers : http://developer.apple.com/iphone/library/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/GestureRecognizers/GestureRecognizers를 만들 수 있습니다. HTML –
덕분에 ...... 토마스 .... – kiran
Logic for air brush.........
- (UIBezierPath *)pathFromPoint:(CGPoint)start toPoint:(CGPoint)end {
CGFloat lineWidth=10;
redrawRect = CGRectMake(end.x-lineWidth,end.y-lineWidth,lineWidth*2,lineWidth*2);
UIBezierPath *bezierPath = [UIBezierPath bezierPath];
UIBezierPath *circle = [UIBezierPath bezierPathWithOvalInRect:redrawRect];
NSInteger i, x, y;
NSInteger modNumber =4*(int)lineWidth;
for (i = 0; i < (lineWidth*lineWidth)/2; i++) {
do {
x = (random() % modNumber)+end.x - 2*lineWidth;
y = (random() % modNumber)+end.y - 2*lineWidth;
} while (![circle containsPoint:CGPointMake(x,y)]);
[bezierPath appendPath:[UIBezierPath bezierPathWithRect:CGRectMake(x,y,0.5,0.5)]];
}
return bezierPath;
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
currentPoint = [touch locationInView:self.view];
currentPoint.y -=20;
[self drawCircle];
}
-(void)drawCircle{
UIGraphicsBeginImageContext(self.drawImage.frame.size);
[drawImage.image drawInRect:CGRectMake(0,0, drawImage.frame.size.width, drawImage.frame.size.height)]; //originally self.frame.size.width, self.frame.size.height)];
CGContextSetLineWidth(UIGraphicsGetCurrentContext(),10);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 0.0, 0.0, 1.0);
UIBezierPath *path=[self pathFromPoint:currentPoint
toPoint:currentPoint];
[path stroke];
lastPoint = currentPoint;
CGContextStrokePath(UIGraphicsGetCurrentContext());
CGContextFlush(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
당신이 분필 선으로 무엇을 의미합니까? – Plumenator
재생을위한 감사장 ... 사실 저는 UIImageView에 에어 브러시를 그리기를 원합니다 ... – kiran