• 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
Re: converting rects between coordinate systems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: converting rects between coordinate systems


  • Subject: Re: converting rects between coordinate systems
  • From: email@hidden
  • Date: Thu, 5 Jun 2003 08:34:57 -0400

The bounds rectangle is mapped onto the frame rectangle. As a result, if the bounds rectangle is the same size as the frame rectangle, then there is a one to one correspondence between coordinates, and the subview's width is indeed the width in screen pixels. On the other hand, if the bounds rectangle is larger than the frame rectangle, the image is scaled down to fit into the frame rectangle. Another way to think of this is to imagine the image being drawn into an infinite plane. The bounds rectangle is a finite plane that decides how much of the image should be included in the final drawing. It is like the lens of a camera. Consequently, the larger the bounds (the farther you stand back), the more of the picture that will be shown, but all the picture is shrunken down to the size of the frame, the actual picture. Thus, when the picture must be displayed, it has to be scaled down to fit into the frame rectangle.

Possible solution:
I need to get the current transformation matrix, but I don't know how.

On Thursday, Jun 5, 2003, at 01:45 America/New_York, j o a r wrote:

I still don't get it, but I'm probably just being a bit dense...

Are you looking for how much a subview is scaled? Shouldn't that be ([mySuperview frame].size.width / [mySuperview bounds].size.width)? At least provided that you "force" subviews to scale with the bounds of the superview, ie. that the subview is set to [mySubview setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)] before the bounds rectangle is scaled differently from the frame rectangle.

Or are you just looking for the width of a subview (you say "the width of these scaled images in screen pixels")? The sizes of the view frames are always in screen pixels, right? Should that not be the width of the frame of the subview?

It seems that you're looking for the width of a subview that is exposed through the hole that is the frame of the superview (you say "the final image may only be 200 pixels wide")? But in that case that should just be the width of the frame of the superview? It should also be a static size - at least as long as the width of the superview / window doesn't change?

But perhaps you also want to take into account that the subview might only expose a corner of it's frame through the hole in the frame of it's superview (do your subviews always fill the size of the bounds of their superview?)? In this case you can ask the subview for it's "visibleRect" and get the width from that.

j o a r

On Thursday, Jun 5, 2003, at 03:45 Europe/Stockholm, email@hidden wrote:

I have several views that represent huge objects. You would laugh at the size and location of their frames. In order to show them entirely on screen, they are placed inside of another view which has an extremely large bounds rectangle (set with scaleUnitSquareToSize:). The result is a scaling of the images of the subviews. It is important for a certain part of the program to calculate the width of these scaled images in screen pixels. In other words, though the frame of a subview is extremely large, the final image may only be 200 pixels wide. That final result is what I seek. I hope this explains the predicament a bit more.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: [fixed] converting rects between coordinate systems
      • From: email@hidden
References: 
 >Re: converting rects between coordinate systems (From: j o a r <email@hidden>)

  • Prev by Date: hacking through Cocoa pasteboards
  • Next by Date: typingAttributes?
  • Previous by thread: Re: converting rects between coordinate systems
  • Next by thread: Re: [fixed] converting rects between coordinate systems
  • Index(es):
    • Date
    • Thread