Question

I can draw a path...and i am somewhat sure that i need to use affine transform.

what i don't get is how to rotate the path and keep the same center.

I apologize for the lack of code here...but all I have is a failed call to CGContextRotateCTM that seemed to halt all drawing.

Was it helpful?

Solution

To rotate around the center:

CGContextTranslateCTM (ctx, center.x, center.y);
CGContextRotateCTM (ctx, angleInRadians);
CGContextTranslateCTM (ctx, -center.x, -center.y);
CGContextAddPath (ctx, path);

I might have the translate signs backward (i.e. negative translation before rotate instead of after), although I believe the CTM methods pre-concat, so the mathematical representation of those calls is

CTMnew = -T * R * T * CTMcurrent
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top