Skip to content

Commit

Permalink
Auto merge of #1289 - kvark:border, r=kvark
Browse files Browse the repository at this point in the history
Border code conversion fix

Previously, specifying 0xFF would produce 1.00196 value.
  • Loading branch information
homu committed Jun 2, 2017
2 parents 1fc02b5 + dd31b5b commit 75553c0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/src/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ pub struct PackedColor(pub u32);
impl From<[f32; 4]> for PackedColor {
fn from(c: [f32; 4]) -> PackedColor {
PackedColor(c.iter().rev().fold(0, |u, &c| {
(u<<8) + (c * 255.0 + 0.5) as u32
(u<<8) + (c * 255.0) as u32
}))
}
}
Expand All @@ -424,7 +424,7 @@ impl Into<[f32; 4]> for PackedColor {
let mut out = [0.0; 4];
for i in 0 .. 4 {
let byte = (self.0 >> (i<<3)) & 0xFF;
out[i] = (byte as f32 + 0.5) / 255.0;
out[i] = byte as f32 / 255.0;
}
out
}
Expand Down

0 comments on commit 75553c0

Please sign in to comment.