• 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
Avoid drawing in half pixel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Avoid drawing in half pixel
      • From: Bill Hernandez <email@hidden>
    • Re: Avoid drawing in half pixel
      • From: Corbin Dunn <email@hidden>
    • Re: Avoid drawing in half pixel
      • From: Rob Ross <email@hidden>
    • Re: Avoid drawing in half pixel
      • From: Simone Tellini <email@hidden>
  • Prev by Date: Re: NSSegmentedControl in a toolbar
  • Next by Date: Re: Avoid drawing in half pixel
  • Previous by thread: Re: UIPickerView and MKMapView
  • Next by thread: Re: Avoid drawing in half pixel
  • Index(es):
    • Date
    • Thread