views:

17

answers:

1

I'm trying to move the origin of a custom view. If I directly set the new origin for the frame, everything is working fine as expected.

[MyView setFrameOrigin:NSMakePoint(0.5, 0.5)];

If I try to animate the movement with the proxy animator.

[[MyView animator] setFrameOrigin:NSMakePoint(0.5, 0.5)];

The new origin will be (1, 1) instead of (0.5, 0.5). Am I doing something wrong? Is animator unable to handle 0.5 points?

+1  A: 

My guess is the animator proxy is helpfully correcting a frame that would result in blurry edges and/or text. Drawing things across pixel borders (0.5, 0.5 vs. 1.0, 1.0 or 0.0, 0.0) is rarely useful unless you're trying to make something blurry (like a shadow, or glow).

You may very well have a good reason for doing this, but it's probably best to ask "why?"

Joshua Nozzi
Yes. Actually what I'm trying to do is this:* an NSView which draws a rounded rect* the rounded rect is drawn starting from an NSRect that is derived from NSInsetRect([self bounds], 0.5, 0.5)* draw a stroke to the NSBezierPath with line width 1.0* add the custom view that I want to animate inside the NSBezierPathFrom my tests 0.5 for inset and 1.0 for line width give me the best visual result.But probably I'm making everything to complicated.
massimoperi
massimoperi: You might prefer to use an inner stroke, as I describe here: http://stackoverflow.com/questions/2488115/how-to-set-up-a-user-quartz2d-coordinate-system-with-scaling-that-avoids-fuzzy-drawing
Peter Hosey