File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ namespace tray {
5
5
struct Rgb : Vec<std::uint8_t , 3 > {
6
6
using Vec::Vec;
7
7
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 ); }
10
10
11
11
static constexpr Rgb from_f32 (fvec3 const & normalized) { return {to_u8 (normalized.x ()), to_u8 (normalized.y ()), to_u8 (normalized.z ())}; }
12
12
Original file line number Diff line number Diff line change @@ -98,6 +98,12 @@ class Vec {
98
98
return *this ;
99
99
}
100
100
101
+ friend constexpr Vec operator -(Vec const & v) {
102
+ auto ret = v;
103
+ ret = -ret;
104
+ return ret;
105
+ }
106
+
101
107
template <VecOrType<Type, Dim> T>
102
108
friend constexpr Vec operator +(Vec const & a, T const & b) {
103
109
auto ret = a;
You can’t perform that action at this time.
0 commit comments