App: use std::lround() to fix linter warnings
This commit is contained in:
@@ -82,10 +82,10 @@ Color& Color::setPackedValue(uint32_t rgba)
|
||||
uint32_t Color::getPackedValue() const
|
||||
{
|
||||
// clang-format off
|
||||
return (static_cast<uint32_t>(r * 255.0F + 0.5F) << 24 |
|
||||
static_cast<uint32_t>(g * 255.0F + 0.5F) << 16 |
|
||||
static_cast<uint32_t>(b * 255.0F + 0.5F) << 8 |
|
||||
static_cast<uint32_t>(a * 255.0F + 0.5F));
|
||||
return (static_cast<uint32_t>(std::lround(r * 255.0F)) << 24 |
|
||||
static_cast<uint32_t>(std::lround(g * 255.0F)) << 16 |
|
||||
static_cast<uint32_t>(std::lround(b * 255.0F)) << 8 |
|
||||
static_cast<uint32_t>(std::lround(a * 255.0F)));
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
@@ -101,19 +101,19 @@ void Color::setPackedRGB(uint32_t rgb)
|
||||
uint32_t Color::getPackedRGB() const
|
||||
{
|
||||
// clang-format off
|
||||
return (static_cast<uint32_t>(r * 255.0F + 0.5F) << 24 |
|
||||
static_cast<uint32_t>(g * 255.0F + 0.5F) << 16 |
|
||||
static_cast<uint32_t>(b * 255.0F + 0.5F) << 8);
|
||||
return (static_cast<uint32_t>(std::lround(r * 255.0F)) << 24 |
|
||||
static_cast<uint32_t>(std::lround(g * 255.0F)) << 16 |
|
||||
static_cast<uint32_t>(std::lround(b * 255.0F)) << 8);
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
uint32_t Color::getPackedARGB() const
|
||||
{
|
||||
// clang-format off
|
||||
return (static_cast<uint32_t>(a * 255.0F + 0.5F) << 24 |
|
||||
static_cast<uint32_t>(r * 255.0F + 0.5F) << 16 |
|
||||
static_cast<uint32_t>(g * 255.0F + 0.5F) << 8 |
|
||||
static_cast<uint32_t>(b * 255.0F + 0.5F));
|
||||
return (static_cast<uint32_t>(std::lround(a * 255.0F)) << 24 |
|
||||
static_cast<uint32_t>(std::lround(r * 255.0F)) << 16 |
|
||||
static_cast<uint32_t>(std::lround(g * 255.0F)) << 8 |
|
||||
static_cast<uint32_t>(std::lround(b * 255.0F)));
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
@@ -131,9 +131,9 @@ std::string Color::asHexString() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "#" << std::hex << std::uppercase << std::setfill('0')
|
||||
<< std::setw(2) << int(r * 255.0F + 0.5F)
|
||||
<< std::setw(2) << int(g * 255.0F + 0.5F)
|
||||
<< std::setw(2) << int(b * 255.0F + 0.5F);
|
||||
<< std::setw(2) << int(std::lround(r * 255.0F))
|
||||
<< std::setw(2) << int(std::lround(g * 255.0F))
|
||||
<< std::setw(2) << int(std::lround(b * 255.0F));
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#ifdef __GNUC__
|
||||
# include <cstdint>
|
||||
#endif
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
|
||||
#include <FCGlobal.h>
|
||||
@@ -130,9 +131,9 @@ public:
|
||||
inline T asValue() const
|
||||
{
|
||||
// clang-format off
|
||||
return(T(int(r * 255.0F + 0.5F),
|
||||
int(g * 255.0F + 0.5F),
|
||||
int(b * 255.0F + 0.5F)));
|
||||
return(T(int(std::lround(r * 255.0F)),
|
||||
int(std::lround(g * 255.0F)),
|
||||
int(std::lround(b * 255.0F))));
|
||||
// clang-format on
|
||||
}
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user