| 85 | } |
| 86 | |
| 87 | Result<MultiColor> MultiColor::decode(std::span<const uint8_t> data) { |
| 88 | qn::ByteReader reader{data}; |
| 89 | auto header = READER_UNWRAP(reader.readU8()); |
| 90 | size_t count = header & 0b00111111; |
| 91 | |
| 92 | Type type; |
| 93 | std::vector<Color3> colors; |
| 94 | |
| 95 | switch (header >> 6) { |
| 96 | case 0b00: return Err("Invalid color type"); |
| 97 | case 0b01: { |
| 98 | type = Type::Static; |
| 99 | colors.push_back(GEODE_UNWRAP(readRgb(reader))); |
| 100 | } break; |
| 101 | |
| 102 | case 0b10: { |
| 103 | type = Type::Tinting; |
| 104 | colors = GEODE_UNWRAP(readColorList(reader, count)); |
| 105 | } break; |
| 106 | |
| 107 | case 0b11: { |
| 108 | type = Type::Gradient; |
| 109 | colors = GEODE_UNWRAP(readColorList(reader, count)); |
| 110 | } break; |
| 111 | } |
| 112 | |
| 113 | return Ok(MultiColor( |
| 114 | type, |
| 115 | std::move(colors) |
| 116 | )); |
| 117 | } |
| 118 | |
| 119 | MultiColor MultiColor::fromColor(const Color3& color) { |
| 120 | return MultiColor(Type::Static, { color }); |
nothing calls this directly
no test coverage detected