(&self)
| 28 | |
| 29 | impl Shortest for chromashift::Color { |
| 30 | fn shortest(&self) -> Option<String> { |
| 31 | [ |
| 32 | Some(Hex::from(*self).to_string()), |
| 33 | Named::try_from(*self).ok().map(|named| named.to_string()), |
| 34 | Some(Srgb::from(*self).round().to_string()), |
| 35 | ] |
| 36 | .into_iter() |
| 37 | .flatten() |
| 38 | .min_by(|a, b| a.len().cmp(&b.len()).then_with(|| a.cmp(b))) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | /// Formats a CSS alpha value (0–1) from chromashift's internal 0–100 representation. |
no test coverage detected