20template <
int Bits,
typename Scalar =
float>
24 static_assert(
Bits > 0 &&
Bits < 32,
"Bits must be between 1 and 31");
浮点数编码器,将浮点值映射到定长无符号整数。 A generic float encoder mapping a float value to N-bit unsigned integer.
Scalar range_
区间范围(max - min)
uint32_t Encode(Scalar value) const
编码:将浮点数映射为无符号整数。 Encodes a float to unsigned integer in range [0, 2^Bits - 1].
Scalar Decode(uint32_t encoded) const
解码:将无符号整数还原为浮点值。 Decodes an unsigned integer to float.
static constexpr uint32_t MaxInt()
获取最大可编码的整数值。 Returns the maximum encodable unsigned integer.
FloatEncoder(Scalar min, Scalar max)
构造函数,设置映射区间 [min, max]。 Constructor specifying the float range [min, max].
LibXR Color Control Library / LibXR终端颜色控制库
constexpr auto max(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最大值
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值