mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-16 14:08:59 +07:00
make_vecX from color and color32
This commit is contained in:
@@ -55,6 +55,9 @@ namespace e2d
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
vec3<f32> make_vec3(const color& c) noexcept;
|
||||
vec4<f32> make_vec4(const color& c) noexcept;
|
||||
|
||||
bool operator<(const color& l, const color& r) noexcept;
|
||||
bool operator==(const color& l, const color& r) noexcept;
|
||||
bool operator!=(const color& l, const color& r) noexcept;
|
||||
|
||||
@@ -55,6 +55,9 @@ namespace e2d
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
vec3<u8> make_vec3(const color32& c) noexcept;
|
||||
vec4<u8> make_vec4(const color32& c) noexcept;
|
||||
|
||||
bool operator<(const color32& l, const color32& r) noexcept;
|
||||
bool operator==(const color32& l, const color32& r) noexcept;
|
||||
bool operator!=(const color32& l, const color32& r) noexcept;
|
||||
|
||||
@@ -139,6 +139,14 @@ namespace e2d
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
vec3<f32> make_vec3(const color& c) noexcept {
|
||||
return make_vec3(c.r, c.g, c.b);
|
||||
}
|
||||
|
||||
vec4<f32> make_vec4(const color& c) noexcept {
|
||||
return make_vec4(c.r, c.g, c.b, c.a);
|
||||
}
|
||||
|
||||
//
|
||||
// color (<,==,!=) color
|
||||
//
|
||||
|
||||
@@ -139,6 +139,14 @@ namespace e2d
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
vec3<u8> make_vec3(const color32& c) noexcept {
|
||||
return make_vec3(c.r, c.g, c.b);
|
||||
}
|
||||
|
||||
vec4<u8> make_vec4(const color32& c) noexcept {
|
||||
return make_vec4(c.r, c.g, c.b, c.a);
|
||||
}
|
||||
|
||||
//
|
||||
// color32 (<,==,!=) color32
|
||||
//
|
||||
|
||||
@@ -48,6 +48,10 @@ TEST_CASE("color") {
|
||||
c /= color(0.1f,0.2f,0.3f,0.4f);
|
||||
REQUIRE(c == color(0.5f,0.6f,0.7f,0.8f));
|
||||
}
|
||||
{
|
||||
REQUIRE(make_vec3(color(0.1f,0.2f,0.3f,0.4f)) == v3f(0.1f,0.2f,0.3f));
|
||||
REQUIRE(make_vec4(color(0.1f,0.2f,0.3f,0.4f)) == v4f(0.1f,0.2f,0.3f, 0.4f));
|
||||
}
|
||||
{
|
||||
REQUIRE(color(0.1f,0.2f,0.3f,0.4f) + 0.1f == color(0.2f,0.3f,0.4f,0.5f));
|
||||
REQUIRE(color(0.1f,0.2f,0.3f,0.4f) - 0.1f == color(0.0f,0.1f,0.2f,0.3f));
|
||||
|
||||
@@ -50,6 +50,10 @@ TEST_CASE("color32") {
|
||||
c /= color32(2,3,6,7);
|
||||
REQUIRE(c == color32(40,50,40,20));
|
||||
}
|
||||
{
|
||||
REQUIRE(make_vec3(color32(10,20,30,40)) == vec3<u8>(10,20,30));
|
||||
REQUIRE(make_vec4(color32(10,20,30,40)) == vec4<u8>(10,20,30,40));
|
||||
}
|
||||
{
|
||||
REQUIRE(color32(10,20,30,40) + 10 == color32(20,30,40,50));
|
||||
REQUIRE(color32(10,20,30,40) - 10 == color32(0,10,20,30));
|
||||
|
||||
Reference in New Issue
Block a user