Take the 2-minute tour ×

I have to program a drawing tool that should display shapes on a plane. These shapes could either be arbitrary shapes, like an elipse or a cube, or some picture that would be drawn on the plane.

What I need to do is, using marker points positioned all around these shapes, be able to transform them by moving the markers. So for instance assuming I have four markers positioned at the top, bottom, left and right, I should be able to stretch the shape horizontally by moving the left and right markers.

I can't use geometric properties of the shape (like changing the radius of the ellipse for instance) since I have to be able to do that on arbitrary shapes (like pictures).

I don't have much experience in image manipulation algorithms, can any one give me some hints of where to start ? Eventually best practice to do it good or even a good algorithm to do that ?

I am developing for the iOS platform.

share|improve this question

2 Answers 2

Have you taken a look at the Quartz 2D Programming Guide in the Apple Developer Center?

share|improve this answer

Here is how you draw onto a UIImage

UIGraphicsBeginImageContext(CGSizeMake(width, height)); 
// do your drawing operations
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 

Here's how you can scale that image

UIGraphicsBeginImageContext(CGSizeMake(scaledWidth, scaledHeight)); 
[image drawInRect:CGRectMake(0,0, scaledWidth, scaledHeight)];
UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext(); 

You don't have to do it in two steps -- you could just draw each item scaled. That would be better for the non image drawing.

If you need a CGContextRef to draw, you can use this

CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
share|improve this answer

Your Answer


