| 46 | // Specialization for s16x16: uses from_raw, no float at all |
| 47 | template<> |
| 48 | inline fl::u8 coordToU8<fl::s16x16>(fl::s16x16 alpha) { |
| 49 | constexpr fl::s16x16 c255 = fl::s16x16::from_raw(255 * fl::s16x16::SCALE); |
| 50 | constexpr fl::s16x16 half = fl::s16x16::from_raw(1 << 15); |
| 51 | return (fl::u8)fl::clamp((alpha * c255 + half).to_int(), (fl::i32)0, (fl::i32)255); |
| 52 | } |
| 53 | |
| 54 | /// Convert an integer to Coord without float intermediate. |
| 55 | /// For s16x16: uses from_raw (pure integer shift). For float: implicit cast. |