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

Author Topic: Operators for IntRect and FloatRect  (Read 4741 times)

0 Members and 1 Guest are viewing this topic.

Deathbeam

  • Jr. Member
  • **
  • Posts: 82
  • VB6, VB.NET, C#, HTML, PHP, CSS, JavaScript nerd.
    • View Profile
    • My portfolio
    • Email
Operators for IntRect and FloatRect
« on: May 20, 2014, 10:28:58 am »
I am not sure if they are in official version, but in SFML.NET they are missing. Atleast operators == and != should be there. I can make pull request for it.
Spooker Framework - Open source gaming library
My portfolio
Indie Armory - Small community of a game developers. Everyone is welcome. Bring your friends, family, pets...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Operators for IntRect and FloatRect
« Reply #1 on: May 20, 2014, 11:14:45 am »
They are in C++ version (it's easy to check...).
Laurent Gomila - SFML developer

Deathbeam

  • Jr. Member
  • **
  • Posts: 82
  • VB6, VB.NET, C#, HTML, PHP, CSS, JavaScript nerd.
    • View Profile
    • My portfolio
    • Email
Re: Operators for IntRect and FloatRect
« Reply #2 on: May 20, 2014, 04:53:41 pm »
It is not that easy, becouse I am totally unexperienced in C++ (and also lazy, easier for me is to ask). Okay, made pull request for that missing operators then: https://github.com/SFML/SFML.Net/pull/55
Spooker Framework - Open source gaming library
My portfolio
Indie Armory - Small community of a game developers. Everyone is welcome. Bring your friends, family, pets...

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Operators for IntRect and FloatRect
« Reply #3 on: May 30, 2014, 11:49:58 am »
How about shrink/expand methods? It can be useful.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Operators for IntRect and FloatRect
« Reply #4 on: May 30, 2014, 12:16:02 pm »
Quote
How about shrink/expand methods? It can be useful.
Useful for what?
Laurent Gomila - SFML developer

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Operators for IntRect and FloatRect
« Reply #5 on: May 30, 2014, 04:31:17 pm »
If you need increase or decrease size of rectangle, just for code beauty. =) For me - it is useful.

template<typename T>
inline void sf::Rect<T>::shrink(T val)
{
    left += val;
    top += val;
    width -= val;
    height -= val;
}
 
« Last Edit: May 30, 2014, 04:33:11 pm by ChronicRat »

Deathbeam

  • Jr. Member
  • **
  • Posts: 82
  • VB6, VB.NET, C#, HTML, PHP, CSS, JavaScript nerd.
    • View Profile
    • My portfolio
    • Email
Re: Operators for IntRect and FloatRect
« Reply #6 on: May 30, 2014, 07:05:31 pm »
If you need increase or decrease size of rectangle, just for code beauty. =) For me - it is useful.

template<typename T>
inline void sf::Rect<T>::shrink(T val)
{
    left += val;
    top += val;
    width -= val;
    height -= val;
}
 
Usefull? I know tons of usefull Vector and Rectangle functions but I still do not think that they should be implemented to SFML. Like
Union, Inflate, Center
 
for Rectangle and
Clamp, Dot, Direction, Distance, Catmull, Lerp, Hermite
 
etc... for Vector
Spooker Framework - Open source gaming library
My portfolio
Indie Armory - Small community of a game developers. Everyone is welcome. Bring your friends, family, pets...

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Operators for IntRect and FloatRect
« Reply #7 on: May 30, 2014, 07:05:49 pm »
For so small functions like this one it's simpler to let everyone implement it on his own way because otherwise we need a lot of different shrink functions to make everybody happy: your function reduce the sides by 2*val toward the center, some people would prefer only 1*val, others might want to reduce it toward the top left corner, ... With all these functions you get a bloated API and everybody get confused.  ;)
SFML / OS X developer

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Operators for IntRect and FloatRect
« Reply #8 on: May 30, 2014, 07:50:59 pm »
Just offered. =) By the way, i'm using GLM as math lib.

 

anything