Avoid drawing in half pixel
Avoid drawing in half pixel
- Subject: Avoid drawing in half pixel
- From: Gustavo Pizano <email@hidden>
- Date: Wed, 5 May 2010 17:18:21 +0200
Hello all.
I have a split view and inside I have custom views, in one subview Im drawing lines with a NSBezierPath, and when I move the divider I see sometimes the lines very thin some others no, so I know this last behavior its because Im drawing in half a pixel.
I was reading the apple docs about this topic, and I tried at the beginning of my drawRect method I did as in "Converting Coordinate Values" topic suggest to convert my starting drawing point, but that din't help. I still see the above behavior.
I realize then that when I resize the window I have the same behavior, so what I did was in the windowDelegate windowWillResize method, I did the following:
if((NSInteger)frameSize.width % 2 != 0){
frameSize.width += 1.0f;
}
if((NSInteger)frameSize.height % 2 != 0){
frameSize.height += 1.0f;
}
and when I resize the window I don't see hte problem anymore. I tried applying this same to the splitview delegate when resizing, but unfortunately this approach didn't work well, I started getting warnings in the console that the size of the subviews weren't correct and it was being recalculated at the cost of performance.
So any other idea on what can I do to avoid this behavior?
Thanks
Gustavo
_______________________________________________
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