mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Increase precision of sf::Rect<T>
operator<<
This has been a recurring problem. I had to add similar code to the sf::Angle operator<< because I was getting tiny floating point differences that after rounding were imperceptable.
This commit is contained in:
parent
cf155fbb1b
commit
2adc3c0e23
@ -9,6 +9,8 @@
|
||||
#include "WindowUtil.hpp"
|
||||
|
||||
#include <SFML/Graphics/Rect.hpp>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
|
||||
namespace sf
|
||||
{
|
||||
@ -23,7 +25,10 @@ namespace sf
|
||||
template <typename T>
|
||||
std::ostream& operator <<(std::ostream& os, const sf::Rect<T>& rect)
|
||||
{
|
||||
const auto flags = os.flags();
|
||||
os << std::fixed << std::setprecision(std::numeric_limits<T>::max_digits10);
|
||||
os << "(left=" << rect.left << ", top=" << rect.top << ", width=" << rect.width << ", height=" << rect.height << ")";
|
||||
os.flags(flags);
|
||||
return os;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user