summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/color.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/color.rs b/src/color.rs
index 45dc5b2..0d83a85 100644
--- a/src/color.rs
+++ b/src/color.rs
@@ -26,10 +26,10 @@ impl Color {
}
pub fn from_rgba_hex(hex: u32) -> Self {
- let r = (hex >> 24 & 0xFF) as u8;
- let g = (hex >> 16 & 0xFF) as u8;
- let b = (hex >> 8 & 0xFF) as u8;
- let a = (hex & 0xFF) as u8;
+ let r = (hex >> 24) as u8;
+ let g = (hex >> 16) as u8;
+ let b = (hex >> 8) as u8;
+ let a = hex as u8;
Self::from_rgba(r, g, b, a)
}
}
@@ -40,9 +40,9 @@ impl FromStr for Color {
fn from_str(color: &str) -> Result<Self, Self::Err> {
let rgb = color.get(1..7).ok_or(())?;
let rgb = u32::from_str_radix(rgb, 16).map_err(|_| ())?;
- let r = (rgb >> 16 & 0xFF) as u8;
- let g = (rgb >> 8 & 0xFF) as u8;
- let b = (rgb & 0xFF) as u8;
+ let r = (rgb >> 16) as u8;
+ let g = (rgb >> 8) as u8;
+ let b = rgb as u8;
let a = match color.get(7..9) {
Some(a) => u8::from_str_radix(a, 16).map_err(|_| ())?,