Color uses 255-format values
This commit is contained in:
parent
aee8435322
commit
d7bedba1f9
|
|
@ -55,7 +55,7 @@ DebugActor::DebugActor()
|
|||
comma_locale_ = std::locale(std::locale(), new comma_numpunct);
|
||||
|
||||
background_brush_ = memory::New<Brush>();
|
||||
background_brush_->SetColor(Color(0.0f, 0.0f, 0.0f, 0.7f));
|
||||
background_brush_->SetColor(Color::Rgba(0x000000, 0.7f));
|
||||
|
||||
BrushPtr fill_brush = memory::New<Brush>();
|
||||
fill_brush->SetColor(Color::White);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ const uint32_t GREEN_MASK = 0xff << GREEN_SHIFT;
|
|||
const uint32_t BLUE_MASK = 0xff << BLUE_SHIFT;
|
||||
} // namespace
|
||||
|
||||
const Color Color::Transparent = Color(0.f, 0.f, 0.f, 0.f);
|
||||
const Color Color::Transparent = Color(0, 0, 0, 0.f);
|
||||
|
||||
Color::Color()
|
||||
: r(0)
|
||||
|
|
@ -43,30 +43,14 @@ Color::Color()
|
|||
{
|
||||
}
|
||||
|
||||
Color::Color(float r, float g, float b)
|
||||
: r(r)
|
||||
, g(g)
|
||||
, b(b)
|
||||
, a(1.f)
|
||||
{
|
||||
}
|
||||
|
||||
Color::Color(float r, float g, float b, float alpha)
|
||||
: r(r)
|
||||
, g(g)
|
||||
, b(b)
|
||||
Color::Color(uint32_t r, uint32_t g, uint32_t b, float alpha)
|
||||
: r(r / 255.0f)
|
||||
, g(g / 255.0f)
|
||||
, b(b / 255.0f)
|
||||
, a(alpha)
|
||||
{
|
||||
}
|
||||
|
||||
Color::Color(uint32_t rgb)
|
||||
: r(((rgb & RED_MASK) >> RED_SHIFT) / 255.f)
|
||||
, g(((rgb & GREEN_MASK) >> GREEN_SHIFT) / 255.f)
|
||||
, b(((rgb & BLUE_MASK) >> BLUE_SHIFT) / 255.f)
|
||||
, a(1.f)
|
||||
{
|
||||
}
|
||||
|
||||
Color::Color(uint32_t rgb, float alpha)
|
||||
: r(((rgb & RED_MASK) >> RED_SHIFT) / 255.f)
|
||||
, g(((rgb & GREEN_MASK) >> GREEN_SHIFT) / 255.f)
|
||||
|
|
@ -75,7 +59,7 @@ Color::Color(uint32_t rgb, float alpha)
|
|||
{
|
||||
}
|
||||
|
||||
Color Color::Rgb(float r, float g, float b)
|
||||
Color Color::Rgb(uint32_t r, uint32_t g, uint32_t b)
|
||||
{
|
||||
return Color::Rgba(r, g, b, 1.0f);
|
||||
}
|
||||
|
|
@ -85,7 +69,7 @@ Color Color::Rgb(uint32_t rgb)
|
|||
return Color::Rgba(rgb, 1.0f);
|
||||
}
|
||||
|
||||
Color Color::Rgba(float r, float g, float b, float alpha)
|
||||
Color Color::Rgba(uint32_t r, uint32_t g, uint32_t b, float alpha)
|
||||
{
|
||||
return Color(r, g, b, alpha);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,8 @@ namespace kiwano
|
|||
* @brief 颜色
|
||||
* @details
|
||||
* 使用枚举表示颜色: @code Color blue = Color::Blue; @endcode
|
||||
* 使用 RGB 表示一个颜色: @code Color red = Color(1.0f, 0.0f, 0.0f); @endcode
|
||||
* 使用 RGBA 表示一个带透明度的颜色: @code Color not_white = Color(1.0f, 1.0f,
|
||||
* 1.0f, 0.5f); @endcode
|
||||
* 使用 RGB 表示一个颜色: @code Color red = Color(255, 0, 0); @endcode
|
||||
* 使用 RGBA 表示一个带透明度的颜色: @code Color not_white = Color(255, 255, 255, 0.5f); @endcode
|
||||
* 使用一个16进制整型值表示 RGB 颜色: @code Color black(0x000000); @endcode
|
||||
*/
|
||||
class KGE_API Color
|
||||
|
|
@ -44,41 +43,29 @@ class KGE_API Color
|
|||
public:
|
||||
/// \~chinese
|
||||
/// @brief 构造颜色
|
||||
/// @details 默认颜色为 R: 0.0, G: 0.0, B: 0.0, A: 1.0
|
||||
/// @details 默认颜色为 R: 0, G: 0, B: 0, A: 1.0
|
||||
Color();
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 构造 RGB 颜色
|
||||
/// @param r 红色值,范围 0.0 - 1.0
|
||||
/// @param g 绿色值,范围 0.0 - 1.0
|
||||
/// @param b 蓝色值,范围 0.0 - 1.0
|
||||
Color(float r, float g, float b);
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 构造 RGBA 颜色
|
||||
/// @param r 红色值,范围 0.0 - 1.0
|
||||
/// @param g 绿色值,范围 0.0 - 1.0
|
||||
/// @param b 蓝色值,范围 0.0 - 1.0
|
||||
/// @param r 红色值,范围 0 - 255
|
||||
/// @param g 绿色值,范围 0 - 255
|
||||
/// @param b 蓝色值,范围 0 - 255
|
||||
/// @param alpha Alpha值,范围 0.0 - 1.0
|
||||
Color(float r, float g, float b, float alpha);
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 构造 RGB 颜色
|
||||
/// @param rgb 使用16进制整形值表示 RGB颜色
|
||||
Color(uint32_t rgb);
|
||||
Color(uint32_t r, uint32_t g, uint32_t b, float alpha = 1.0f);
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 构造 RGBA 颜色
|
||||
/// @param rgb 使用16进制整形值表示 RGB 颜色
|
||||
/// @param alpha Alpha值,范围 0.0 - 1.0
|
||||
Color(uint32_t rgb, float alpha);
|
||||
Color(uint32_t rgb, float alpha = 1.0f);
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 构造 RGB 颜色
|
||||
/// @param r 红色值,范围 0.0 - 1.0
|
||||
/// @param g 绿色值,范围 0.0 - 1.0
|
||||
/// @param b 蓝色值,范围 0.0 - 1.0
|
||||
static Color Rgb(float r, float g, float b);
|
||||
/// @param r 红色值,范围 0 - 255
|
||||
/// @param g 绿色值,范围 0 - 255
|
||||
/// @param b 蓝色值,范围 0 - 255
|
||||
static Color Rgb(uint32_t r, uint32_t g, uint32_t b);
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 构造 RGB 颜色
|
||||
|
|
@ -87,11 +74,11 @@ public:
|
|||
|
||||
/// \~chinese
|
||||
/// @brief 构造 RGBA 颜色
|
||||
/// @param r 红色值,范围 0.0 - 1.0
|
||||
/// @param g 绿色值,范围 0.0 - 1.0
|
||||
/// @param b 蓝色值,范围 0.0 - 1.0
|
||||
/// @param r 红色值,范围 0 - 255
|
||||
/// @param g 绿色值,范围 0 - 255
|
||||
/// @param b 蓝色值,范围 0 - 255
|
||||
/// @param alpha Alpha值,范围 0.0 - 1.0
|
||||
static Color Rgba(float r, float g, float b, float alpha);
|
||||
static Color Rgba(uint32_t r, uint32_t g, uint32_t b, float alpha);
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 构造 RGBA 颜色
|
||||
|
|
|
|||
Loading…
Reference in New Issue