Class for move, scale and rotate, of a uiimageview?

I figured it out... I answered my own question Hopefully this is useful to someone For anyone who is interested, here is the implementation for a UIImageView subclass, that you can use to move, scale, and rotate an image. It works pretty well for me (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if( touches count == 1 ) { float difx = touches anyObject locationInView:self. X - touches anyObject previousLocationInView:self.

X; float dify = touches anyObject locationInView:self. Y - touches anyObject previousLocationInView:self. Y; CGAffineTransform newTransform1 = CGAffineTransformTranslate(self.

Transform, difx, dify); self. Transform = newTransform1; } else if( touches count == 2 ) { int prevmidx = (touches allObjects objectAtIndex:0 previousLocationInView:self. X + touches allObjects objectAtIndex:1 previousLocationInView:self.

X) / 2; int prevmidy = (touches allObjects objectAtIndex:0 previousLocationInView:self. Y + touches allObjects objectAtIndex:1 previousLocationInView:self. Y) / 2; int curmidx = (touches allObjects objectAtIndex:0 locationInView:self.

X + touches allObjects objectAtIndex:1 locationInView:self. X) / 2; int curmidy = (touches allObjects objectAtIndex:0 locationInView:self. Y + touches allObjects objectAtIndex:1 locationInView:self.

Y) / 2; int difx = curmidx - prevmidx; int dify = curmidy - prevmidy; CGPoint prevPoint1 = touches allObjects objectAtIndex:0 previousLocationInView:self; CGPoint prevPoint2 = touches allObjects objectAtIndex:1 previousLocationInView:self; CGPoint curPoint1 = touches allObjects objectAtIndex:0 locationInView:self; CGPoint curPoint2 = touches allObjects objectAtIndex:1 locationInView:self; float prevDistance = self distanceBetweenPoint1:prevPoint1 andPoint2:prevPoint2; float newDistance = self distanceBetweenPoint1:curPoint1 andPoint2:curPoint2; float sizeDifference = (newDistance / prevDistance); CGAffineTransform newTransform1 = CGAffineTransformTranslate(self. Transform, difx, dify); self. Transform = newTransform1; CGAffineTransform newTransform2 = CGAffineTransformScale(self.

Transform, sizeDifference, sizeDifference); self. Transform = newTransform2; float prevAngle = self angleBetweenPoint1:prevPoint1 andPoint2:prevPoint2; float curAngle = self angleBetweenPoint1:curPoint1 andPoint2:curPoint2; float angleDifference = curAngle - prevAngle; CGAffineTransform newTransform3 = CGAffineTransformRotate(self. Transform, angleDifference); self.

Transform = newTransform3; } } - (NSInteger)distanceBetweenPoint1:(CGPoint)point1 andPoint2:(CGPoint)point2 { CGFloat deltaX = fabsf(point1. X - point2. X); CGFloat deltaY = fabsf(point1.

Y - point2. Y); CGFloat distance = sqrt((deltaY*deltaY)+(deltaX*deltaX)); return distance; } - (CGFloat)angleBetweenPoint1:(CGPoint)point1 andPoint2:(CGPoint)point2 { CGFloat deltaY = point1. Y - point2.

Y; CGFloat deltaX = point1. X - point2. X; CGFloat angle = atan2(deltaY, deltaX); return angle; }.

I figured it out... I answered my own question. Hopefully this is useful to someone. For anyone who is interested, here is the implementation for a UIImageView subclass, that you can use to move, scale, and rotate an image.It works pretty well for me.

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if( touches count == 1 ) { float difx = touches anyObject locationInView:self. X - touches anyObject previousLocationInView:self. X; float dify = touches anyObject locationInView:self.

Y - touches anyObject previousLocationInView:self. Y; CGAffineTransform newTransform1 = CGAffineTransformTranslate(self. Transform, difx, dify); self.

Transform = newTransform1; } else if( touches count == 2 ) { int prevmidx = (touches allObjects objectAtIndex:0 previousLocationInView:self. X + touches allObjects objectAtIndex:1 previousLocationInView:self. X) / 2; int prevmidy = (touches allObjects objectAtIndex:0 previousLocationInView:self.

Y + touches allObjects objectAtIndex:1 previousLocationInView:self. Y) / 2; int curmidx = (touches allObjects objectAtIndex:0 locationInView:self. X + touches allObjects objectAtIndex:1 locationInView:self.

X) / 2; int curmidy = (touches allObjects objectAtIndex:0 locationInView:self. Y + touches allObjects objectAtIndex:1 locationInView:self. Y) / 2; int difx = curmidx - prevmidx; int dify = curmidy - prevmidy; CGPoint prevPoint1 = touches allObjects objectAtIndex:0 previousLocationInView:self; CGPoint prevPoint2 = touches allObjects objectAtIndex:1 previousLocationInView:self; CGPoint curPoint1 = touches allObjects objectAtIndex:0 locationInView:self; CGPoint curPoint2 = touches allObjects objectAtIndex:1 locationInView:self; float prevDistance = self distanceBetweenPoint1:prevPoint1 andPoint2:prevPoint2; float newDistance = self distanceBetweenPoint1:curPoint1 andPoint2:curPoint2; float sizeDifference = (newDistance / prevDistance); CGAffineTransform newTransform1 = CGAffineTransformTranslate(self.

Transform, difx, dify); self. Transform = newTransform1; CGAffineTransform newTransform2 = CGAffineTransformScale(self. Transform, sizeDifference, sizeDifference); self.

Transform = newTransform2; float prevAngle = self angleBetweenPoint1:prevPoint1 andPoint2:prevPoint2; float curAngle = self angleBetweenPoint1:curPoint1 andPoint2:curPoint2; float angleDifference = curAngle - prevAngle; CGAffineTransform newTransform3 = CGAffineTransformRotate(self. Transform, angleDifference); self. Transform = newTransform3; } } - (NSInteger)distanceBetweenPoint1:(CGPoint)point1 andPoint2:(CGPoint)point2 { CGFloat deltaX = fabsf(point1.

X - point2. X); CGFloat deltaY = fabsf(point1. Y - point2.

Y); CGFloat distance = sqrt((deltaY*deltaY)+(deltaX*deltaX)); return distance; } - (CGFloat)angleBetweenPoint1:(CGPoint)point1 andPoint2:(CGPoint)point2 { CGFloat deltaY = point1. Y - point2. Y; CGFloat deltaX = point1.

X - point2. X; CGFloat angle = atan2(deltaY, deltaX); return angle; }.

You might also look at Erica Sadun's example from the iphone dev cookbook (oreilly). It's in chapter 8 on gestures and touches. github.com/erica/iphone-3.0-cookbook-/tr....

CGAffineTransform newTransform2 = CGAffineTransformScale(self. CGAffineTransform newTransform3 = CGAffineTransformRotate(self. CGFloat deltaX = fabsf(point1.

X - point2.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions