avm2: Fix incorrect color in drawing API

This commit is contained in:
Mike Welsh 2021-03-24 01:52:51 -07:00
parent 9a08b9ae4f
commit 040da925e4
1 changed files with 4 additions and 8 deletions

View File

@ -31,14 +31,10 @@ pub fn class_init<'gc>(
Ok(Value::Undefined) Ok(Value::Undefined)
} }
/// Convert a `color`/`alpha` argument pair into a `swf::Color`. /// Convert an RGB `color` and `alpha` argument pair into a `swf::Color`.
fn color_from_args(color: u32, alpha: f64) -> Color { /// `alpha` is normalized from 0.0 - 1.0.
let r = (color & 0xFF0000 >> 16) as u8; fn color_from_args(rgb: u32, alpha: f64) -> Color {
let g = (color & 0x00FF00 >> 8) as u8; Color::from_rgb(rgb, (alpha * 255.0) as u8)
let b = (color & 0x0000FF) as u8;
let a = (alpha * 255.0) as u8;
Color { r, g, b, a }
} }
/// Implements `Graphics.beginFill`. /// Implements `Graphics.beginFill`.