32 lines
530 B
C++
32 lines
530 B
C++
export module core.image;
|
|
|
|
import core;
|
|
|
|
export namespace core {
|
|
struct color {
|
|
float r;
|
|
|
|
float g;
|
|
|
|
float b;
|
|
|
|
float a;
|
|
|
|
u8 to_r8() const {
|
|
return static_cast<u8>(round32(clamp(this->r, 0.0f, 1.0f) * u8_max));
|
|
}
|
|
|
|
u8 to_g8() const {
|
|
return static_cast<u8>(round32(clamp(this->g, 0.0f, 1.0f) * u8_max));
|
|
}
|
|
|
|
u8 to_b8() const {
|
|
return static_cast<u8>(round32(clamp(this->b, 0.0f, 1.0f) * u8_max));
|
|
}
|
|
|
|
u8 to_a8() const {
|
|
return static_cast<u8>(round32(clamp(this->a, 0.0f, 1.0f) * u8_max));
|
|
}
|
|
};
|
|
}
|