On Wed, Jun 9, 2010 at 12:22, Graeme Geldenhuys <[email protected]> wrote: > Op 2010-06-09 12:08, Aleksa Todorovic het geskryf: >> point of view regarding coordinates. You assume that integer >> coordinates represent center of pixel, but they actually represent >> top-left corner of pixel. In other words, think of coordinate 0 as >> 0.0, not 0.5 and the math will work perfectly fine :-) > > > An if you read the rest of my reply, you would have seen the reason why I > use that coordinate system, instead of the intersecting lines (and rather > like a spreadsheet or TStringGrid). The way the OS graphics system works > (at least for GDI & X11) - confirms my thinking. If you have a 1x1 pixel at > (0,0) on the screen, the mouse cursor can be anywhere inside the 1x1 > rectangle (rectangle with the x in image below), and the OS reports it as > location (0,0). My coordinate system reflects this behaviour. If only the > top/left corner (intersecting lines) was (0,0), then my mouse cursor would > also have to be in the top/left corner before the OS reports (0,0) - which > it doesn't. > > 0 1 > +---+---+--- > 0 | x | | > +-+-+---+--- > 1 | | | > +-+-+---+--- > 2 | | | > +-+-+---+--- >
Let's imagine (it doesn't have to be true) that OS calculates mouse coordinates as floating point values. In that case your mouse coordinates are in the range (0.0 - 0.999999), but OS reports it as (0, 0), which means that OS internally calls Trunc. So, you can think of coordinates as Trunc-ed (not Round-ed!) version of real coordinates. > > Regards, > - Graeme - > > -- > fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal > http://opensoft.homeip.net/fpgui/ > > _______________________________________________ > fpc-devel maillist - [email protected] > http://lists.freepascal.org/mailman/listinfo/fpc-devel > -- Aleksa Todorovic - Lead Programmer Eipix Entertainment www eipix com _______________________________________________ fpc-devel maillist - [email protected] http://lists.freepascal.org/mailman/listinfo/fpc-devel
