Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::Rect<T>.MoveAbsolute  (Read 3038 times)

0 Members and 1 Guest are viewing this topic.

wilbefast

  • Newbie
  • *
  • Posts: 31
    • View Profile
    • http://wilbefast.com
sf::Rect<T>.MoveAbsolute
« 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

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
sf::Rect<T>.MoveAbsolute
« Reply #1 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.

wilbefast

  • Newbie
  • *
  • Posts: 31
    • View Profile
    • http://wilbefast.com
sf::Rect<T>.MoveAbsolute
« Reply #2 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  :?

 

anything