Skip to content

Commit

Permalink
reading and writing materials
Browse files Browse the repository at this point in the history
  • Loading branch information
francisdb committed Mar 1, 2024
1 parent 6046960 commit 3b876f0
Show file tree
Hide file tree
Showing 5 changed files with 641 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/vpx/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,20 @@ impl<'de> Deserialize<'de> for ColorJson {
}

impl Color {
pub fn new_argb(arg: u32) -> Color {
pub fn from_argb(arg: u32) -> Color {
let a = ((arg >> 24) & 0xff) as u8;
let r = ((arg >> 16) & 0xff) as u8;
let g = ((arg >> 8) & 0xff) as u8;
let b = (arg & 0xff) as u8;
Color { a, r, g, b }
}

// deprecated
#[deprecated(since = "0.1.0", note = "Please use `from_argb` instead")]
pub fn new_argb(arg: u32) -> Color {
Self::from_argb(arg)
}

pub fn new_bgr(arg: u32) -> Color {
let a = ((arg >> 24) & 0xff) as u8;
let b = ((arg >> 16) & 0xff) as u8;
Expand Down
8 changes: 4 additions & 4 deletions src/vpx/gameitem/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ impl Default for Light {
let status: u32 = Default::default();
let state: Option<f32> = None;
// should these not have alpha ff?
let color: Color = Color::new_argb(0xffff00);
let color2: Color = Color::new_argb(0xffffff);
let color: Color = Color::from_argb(0xffff00);
let color2: Color = Color::from_argb(0xffffff);
let is_timer_enabled: bool = false;
let timer_interval: u32 = Default::default();
let blink_pattern: String = "10".to_owned();
Expand Down Expand Up @@ -464,8 +464,8 @@ mod tests {
falloff_power: 3.0,
status: 4,
state: Some(5.0),
color: Color::new_argb(0x123456),
color2: Color::new_argb(0x654321),
color: Color::from_argb(0x123456),
color2: Color::from_argb(0x654321),
is_timer_enabled: true,
timer_interval: 7,
blink_pattern: "test pattern".to_string(),
Expand Down
Loading

0 comments on commit 3b876f0

Please sign in to comment.