Graphics Rounding (was Re: Pixel-aligned autoresizing)

2011-07-09 Thread Eric Wasylishen
Hi Philippe, The jumping is caused by our use of rint() in NSButtonCell - in fact, I think we should avoid rint() entirely for graphics, because it uses a "round halfway cases to the nearest even integer" algorithm; so 1.5 rounds to 2, but 2.5 also rounds to 2. The annoying thing is that non

Re: Graphics Rounding (was Re: Pixel-aligned autoresizing)

2011-07-10 Thread Fred Kiefer
On 09.07.2011 21:04, Eric Wasylishen wrote: Hi Philippe, The jumping is caused by our use of rint() in NSButtonCell - in fact, I think we should avoid rint() entirely for graphics, because it uses a "round halfway cases to the nearest even integer" algorithm; so 1.5 rounds to 2, but 2.5 also r

Re: Graphics Rounding (was Re: Pixel-aligned autoresizing)

2011-07-10 Thread Eric Wasylishen
On 2011-07-10, at 1:51 PM, Fred Kiefer wrote: > On 09.07.2011 21:04, Eric Wasylishen wrote: >> Hi Philippe, >> >> The jumping is caused by our use of rint() in NSButtonCell - in fact, I >> think we should avoid rint() entirely for graphics, because it uses a "round >> halfway cases to the near

Re: Graphics Rounding (was Re: Pixel-aligned autoresizing)

2011-07-11 Thread Philippe Roussel
Hi Le dimanche 10 juillet 2011 à 21:51 +0200, Fred Kiefer a écrit : > On 09.07.2011 21:04, Eric Wasylishen wrote: > > Hi Philippe, > > > > The jumping is caused by our use of rint() in NSButtonCell - in fact, I > > think we should avoid rint() entirely for graphics, because it uses a > > "round

Re: Graphics Rounding (was Re: Pixel-aligned autoresizing)

2011-07-11 Thread Riccardo Mottola
Hi, Sure. We have this code in NSButtonCell drawImage:withFrame:inView: position.x = MAX(NSMidX(cellFrame) - (size.width / 2.), 0.); position.y = MAX(NSMidY(cellFrame) - (size.height / 2.), 0.); Suppose position.x is 16.5, then rint() would round that to 16, so the image will be drawn half a

Re: Graphics Rounding (was Re: Pixel-aligned autoresizing)

2011-07-11 Thread Eric Wasylishen
On 2011-07-11, at 1:23 AM, Riccardo Mottola wrote: > Hi, > >>> Sure. We have this code in NSButtonCell drawImage:withFrame:inView: >>> >>> position.x = MAX(NSMidX(cellFrame) - (size.width / 2.), 0.); >>> position.y = MAX(NSMidY(cellFrame) - (size.height / 2.), 0.); >>> >>> Suppose position.x i

Re: Graphics Rounding (was Re: Pixel-aligned autoresizing)

2011-07-11 Thread Tim Schmielau
On 11 Jul 2011, at 08:23, Riccardo Mottola wrote: > To my knowledge, rint() doesn't do any advanced rounding. It doesn't try to > minimize the error by rounding odd numbers down and even up or something like > that, it uses a standard round direction. 16.5 will become 17 as 17.5 will > become

Re: Graphics Rounding (was Re: Pixel-aligned autoresizing)

2011-07-12 Thread Riccardo Mottola
Hi, Note that with steps of 0.1 you will not see the round-to-nearest-even behavior, as it will not trip on the exact halfway points due to rounding errors. Increment by 0.25 to check whether round-to-nearest-even is in action. Perhaps indeed, however Eric already has proven rounding to

Re: Graphics Rounding (was Re: Pixel-aligned autoresizing)

2011-07-12 Thread Eric Wasylishen
Hi, I committed the change which I proposed earlier, introducing the following in GSGuiPrivate.h: /** * Rounds to the nearest integer, and in the case of ties, round to the * larger integer. This is the recommended rounding function for rounding * graphics points. * * For example: * GSRoun

Re: Graphics Rounding (was Re: Pixel-aligned autoresizing)

2011-07-13 Thread Philippe Roussel
Le mardi 12 juillet 2011 à 15:18 -0600, Eric Wasylishen a écrit : > Hi, > I committed the change which I proposed earlier, introducing the following in > GSGuiPrivate.h: > > /** > * Rounds to the nearest integer, and in the case of ties, round to the > * larger integer. This is the recommended

Re: Graphics Rounding (was Re: Pixel-aligned autoresizing)

2011-07-20 Thread David Chisnall
On the topic of rounding, there is one new Foundation function introduced with 10.7: NSRect NSIntegralRect (NSRect aRect, NSAlignmentOptions opts); NSAlignmentOptions is an enumerated type specifying rounding directions. David ___ Gnustep-dev mailing