SFML community forums

General => Feature requests => Topic started by: wilbefast on October 14, 2010, 10:53:54 pm

Title: sf::Rect<T>.MoveAbsolute
Post by: wilbefast on October 14, 2010, 10:53:54 pm
Hi everyone,

Loving the library, but a few functions I'd like to see. It would also be good to be able to move an sf::IntRect to a position without doing two Offsets in a row:

Code: [Select]
void sf::IntRect MoveAbsolute(int x, int y)
{
   Offset(rect.Left,rectTop);
   Offset(newX,newY);
}


Yes, I have obsessive compulsive disorder. I also don't know how to use Templates:

Code: [Select]
void moveRect(sf::FloatRect& rect, float x, float y)
{
    rect.Right += x - rect.Left;
    rect.Bottom += y - rect.Top;
    rect.Left = x;
    rect.Top = y;
}

void centreRect(sf::FloatRect& rect, float x, float y)
{
    moveRect(rect,x-rect.GetWidth()/2,y-rect.GetHeight()/2);
}


The second function is one that I use constantly, but it's probably a bit to specific for a library that's supposed to be very simple. Also the main reason I use it is because I didn't realise that SFML supported views, so I wrote my own :?

That's all I can think of for now, but unless I write this stuff down I'll forget about it and/or kludge my way around it.

Tanks,

William
Title: sf::Rect<T>.MoveAbsolute
Post by: Tank on October 15, 2010, 11:01:58 am
That kind of operation won't be needed in the future, as the sf::Rect's behaviour has changed for SFML 2. It now contains Left, Top, Width and Height instead of Right and Bottom.
Title: sf::Rect<T>.MoveAbsolute
Post by: wilbefast on October 15, 2010, 01:52:39 pm
Interesting...

Yes, that does seem more logical  :)  Though I will have to rewrite a some code when it is released  :?