SFML community forums
Help => General => Topic started by: pabloist on September 19, 2010, 08:52:05 am
-
I don't really understand how the rect class works; the reference says
Rect (T LeftCoord, T TopCoord, T RightCoord, T BottomCoord)
but coordinates need to be pairs of numbers, right? so how does an IntRect work? That requires using single integers for each coordinate..?
I'd appreciate if someone could explain (:
-
I think other people have been confused by the use of 'coord' before but I find sf::Rect much simpler to use and understand than other rect implementations.
Left, Top, Right, Bottom refer to the positions of the 'sides' or 'edges'. Left and Right are on the X axis, Top and Bottom are on Y.
So Left is the X coordinate of the Left side/edge and Top is the Y coordinate of the Top side/edge. So the point at (Left, Top) would be the top left corner of the rect.
Hard to explain in words! Make sense though?
-
Hmm, you got the TopLeft coordinates and the BottomRight ones, what do you need more for an Rectangle?
If you don't know what i mean, look at this:
Top/Left------------------Top/Right
| |
| |
| |
| |
Bottom/Left------------Bottom/Right
-
You should take a look at the sf::Rect class template in SFML 2. It uses Left, Top, Width and Height. As far as I remember, one of the decisive reasons why Laurent changed the API was the confusion coming up again and again, concerning whether Bottom/Right coordinates were inclusive or exclusive.
-
Thanks very much everyone (: That clears it up a lot for me.