Skip to content

Commit 38bd48c

Browse files
committed
Hotfixes
- `Rgb`: Fix originally reversed `/` and `*` logic. - `Vec`: add missing friend function for `operator-`.
1 parent 6e03973 commit 38bd48c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

tray/src/tray/rgb.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ namespace tray {
55
struct Rgb : Vec<std::uint8_t, 3> {
66
using Vec::Vec;
77

8-
static constexpr float to_f32(std::uint8_t channel) { return static_cast<float>(channel) * 0xff; }
9-
static constexpr std::uint8_t to_u8(float channel) { return static_cast<std::uint8_t>(channel / 0xff); }
8+
static constexpr float to_f32(std::uint8_t channel) { return static_cast<float>(channel) / 0xff; }
9+
static constexpr std::uint8_t to_u8(float channel) { return static_cast<std::uint8_t>(channel * 0xff); }
1010

1111
static constexpr Rgb from_f32(fvec3 const& normalized) { return {to_u8(normalized.x()), to_u8(normalized.y()), to_u8(normalized.z())}; }
1212

tray/src/tray/vec.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ class Vec {
9898
return *this;
9999
}
100100

101+
friend constexpr Vec operator-(Vec const& v) {
102+
auto ret = v;
103+
ret = -ret;
104+
return ret;
105+
}
106+
101107
template <VecOrType<Type, Dim> T>
102108
friend constexpr Vec operator+(Vec const& a, T const& b) {
103109
auto ret = a;

0 commit comments

Comments
 (0)