gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Graphics Rounding (was Re: Pixel-aligned autoresizing)


From: Eric Wasylishen
Subject: Graphics Rounding (was Re: Pixel-aligned autoresizing)
Date: Sat, 9 Jul 2011 13:04:53 -0600

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 none of the C standard library functions implement a 
good rounding algorithm for graphics. c99's round() rounds halfway cases away 
from zero. This is probably OK in practice but not ideal, since it means the 
location of the coordinate system origin affects the rounding. I think the best 
algorithm for graphics is round-towards-infinity, so just floor(x+0.5). I 
wonder if we should just introduce this as a function for internal use, like 
GSRoundTowardsInfinity().

Eric

On 2011-07-09, at 5:56 AM, Philippe Roussel wrote:

> Hi all,
> 
> Le samedi 09 juillet 2011 à 00:54 +0200, Fred Kiefer a écrit :
>> On 08.07.2011 23:56, Eric Wasylishen wrote:
> 
> [snip]
> 
>>> I think it's safe to do. I went ahead and removed most of the
>> rounding in cairo. If it causes serious problems we can always revert
>> but things look OK to me. Also, the PixelExactDrawing-test is now very
>> close to Cocoa.
>> 
>> Eric,
>> 
>> thank you very much for the great work you are doing here!
> 
> Maybe I'm not responding to the right thread but I just updated to svn
> revision 33493 and I'm observing a strange drawing behaviour.
> 
> In the calendar view of SimpleAgenda I'm using 4 bitmap NSButtons to
> implement the arrows used to navigate between months. The 2 screenshots
> attached show how those arrows are moving up and down when resizing the
> main window (between the 2 pictures I only changed the vertical size).
> 
> The 4 bitmaps have an odd vertical size (9 and 11) and the 4 NSButtons
> have an even vertical size (20) and I understand that it's impossible to
> center a 9 pixels bitmap in a 20 pixel button but I don't understand why
> the bitmap's position change when resizing the window.
> 
> Of course when using an odd button size the bitmaps don't move so I just
> have to clean my own mess to fix this !
> 
> Thanks,
> Philippe
> <calendar-1.png><calendar-2.png>_______________________________________________
> Gnustep-dev mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/gnustep-dev




reply via email to

[Prev in Thread] Current Thread [Next in Thread]