Re: Moveable/Resizable "Box" views and blurry frame
Re: Moveable/Resizable "Box" views and blurry frame
- Subject: Re: Moveable/Resizable "Box" views and blurry frame
- From: Yann Bizeul <email@hidden>
- Date: Tue, 31 Jul 2007 17:33:27 +0200
Thanks for your answer,
The problem is that, when zoomed, 0.5 is no longer in the middle of a
pixel. You have to scale that offset
Yes, I'm aware of that, and that is what I tried too.
I determine my scale by getting the ratio of my contentView's frame
and my contentView's bounds (You mentioned NSScreen and NSWindow
methods, but this is not applicable here, I'm not talking about
resolution independance drawing, but drawing in a zoomed NSScrollView)
But I can't get the magic formula to apply in the drawRect method of
my view.
I tried to draw the rect by after applying a 0.5*ratio offset,
without success, which makes sense to me since I'm not even sure to
be on integer coordinates. But even using NSIntegralRect on my frame
do not solve the problem.
I tried disabling antialias, which could be ok, but I still see
artefact when moving the view, sometimes the line is not draw in the
right place.
That's why I'm trying to get a perfect result, with antialias enabled
so that I can see on screen immediatly if it is good or wrong.
Regards,
Yann Bizeul - yann at tynsoe.org
Cocoa Developer
Tynsoe Projects
BuddyPop - GeekTool - SSH Tunnel Manager - ...
http://projects.tynsoe.org/
Le 30 juil. 07 à 19:34, Clark Cox a écrit :
On 7/30/07, Yann Bizeul <email@hidden> wrote:
Hello list,
I'm working on an application that provides some kind of layout to
arrange boxes on a page, like in a sketch application.
As long as I do not zoom my view, I can get everything to work just
fine, moving the view, resize with handles, etc...
But I need to provide a zoom feature, which I implemented using
scaleUnitSquareToSize on the contentView of my NSScrollView.
The side effect is that, if a coordinate in the middle of the
pixel (.
5) in 1:1 ratio is ok to draw a one pixel clear line, this is no
longer applicable when the view is zoomed.
The problem is that, when zoomed, 0.5 is no longer in the middle of a
pixel. You have to scale that offset
See: <http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaDrawingGuide/Transforms/chapter_4_section_2.html>,
especially the section titled "Pixel-Exact Drawing"
--
Clark S. Cox III
email@hidden
_______________________________________________
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