successive transformations
successive transformations
- Subject: successive transformations
- From: David Harper <email@hidden>
- Date: Wed, 11 Jul 2007 10:59:06 -0400 (EDT)
Hi,
I am performing custom text layout using a layoutmanager to draw text. The view's isFlipped method has been overridden to return yes. Before I move on to more complicated layout, I've decided to try to implement a custom subscript using NSAffineTransform scaling and translation. I've come up with a transformation order that should work in theory, but is possibly being hindered by my lack of specific NSAffineTransform understanding.
Without scaling I'm not having any problems... But I'm trying to implement scaling so that subscripted characters are slightly smaller than normal ones, lets say 0.8* the size. What I do to perform the scaling is:
1. obtain the character rectangle for the single character I'm positioning using [layoutManager rectArrayForCharacterRange:(i,1) withinSelectedRange:(i,1) ..]
2. get the origin of that rectangle.
3. save the graphics state [context saveGraphicsState]
4. create an affine transformation NSAffineTransform *t = [... transform]
5. translate that character to the origin using [t translateXBy:-o.x yBy:-o.y]
6. perform the scaling [t scaleBy:0.8]
7. reverse the initial transformation [t translateXBy:o.x/0.8 yBy:o.y/0.8]
8. apply my subscripting transformation [t translateXBy:offset.x/0.8 yBy:offset.y/0.8]
9. concatenate the transformation, and draw the character
For one thing, apparently scaleBy affects the entire coordinate system, so subsequent translations have to be divided by this number to work properly. I'm trying to get around this by using multiple calls to [t concat] but this doesn't seem to work. Is [t applyTransform: ] helpful?
Thanks
-Dave H.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden