On 7 Feb 2009, at 10:32 am, Adam Gerson wrote:

I have a few custom views on my window that have custom drawing in
them that contain some game pieces that move within the views. The
drawing needs to happen at specific x,y,width,height relative to the
window and each other. None of this can be static if the size of the
window frame is going to get bigger or smaller. It presents the added
challenge of calculating relative locations for everything. I have
worked with AffineTransforms before and will look into that. I
remember playing old some full screen video games that appear to
adjust the resolution of the monitor, shapes appear somewhat blurred,
not terrible, but not good either.


If I've understood you, there's an easy way to do this that avoids the need for every object to have to deal with working out its position relative to the view.

NSView has -scaleUnitSquareToSize: which sets up a transform for the whole view that scales the underlying coordinate system. Objects drawn in the view always "see" the same relative positions within the view and to each other, but appear at different sizes on screen. Effectively this method implements a zoom. Depending on how your objects are drawn, there need not be any loss of sharpness - if you're drawing using NSBezierPath with strokes and fills, or images that contain PDFs, it will remain sharp. Bitmap images will blur and pixellate if the scale is changed so much that the pixels become noticeable, but it sounds to me that for just adjusting the scale to match the screen this probably wouldn't happen as the scale change required is not that much.

hth,

--Graham


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to