static color32::byte to_byte(sample s) noexcept { return static_cast<color32::byte>(color32::BYTE_MAX * s.value()); }
sample operator/(sample a, sample b) { return sample{a.value() / b.value()}; }
sample operator-(sample a, sample b) { return sample{a.value() - b.value()}; }
sample operator+(sample a, sample b) { return sample{a.value() + b.value()}; }
sample sample::operator*(sample other) const { sample result; result.value_ = value() * other.value(); // can't overflow return result; }
sample interpolate(sample a, sample weight, sample b) { return sample{(1 - weight.value()) * a.value() + weight.value() * b.value()}; }