• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
successive transformations
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Prev by Date: Re: Problem using map template in Cocoa
  • Next by Date: Re: Core Data and Document Packages
  • Previous by thread: Re: Linker flags set incorrectly ?
  • Next by thread: Aggregations in a DAG with a Recursive Core Data Structure
  • Index(es):
    • Date
    • Thread