Skip to content

Commit

Permalink
more docs and more methods for colour
Browse files Browse the repository at this point in the history
  • Loading branch information
Sreyas-Sreelal committed May 20, 2024
1 parent 59807ec commit ab749df
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
31 changes: 31 additions & 0 deletions omp-gdk/src/types/colour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,35 @@ impl Colour {
},
}
}

pub fn from_argb(from: u32) -> Colour {
Colour {
data: ColourData {
rgba: std::mem::ManuallyDrop::new(Rgba {
a: ((from & 0xFF000000) >> 24) as u8,
r: ((from & 0x00FF0000) >> 16) as u8,
g: ((from & 0x0000FF00) >> 8) as u8,
b: (from & 0x000000FF) as u8,
}),
},
}
}

pub fn rgba(&self) -> u32 {
unsafe {
(((self.data.rgba.r as u32) << 24) & 0xFF000000)
| (((self.data.rgba.g as u32) << 16) & 0x00FF0000)
| (((self.data.rgba.b as u32) << 8) & 0x0000FF00)
| ((self.data.rgba.a as u32) & 0x000000FF)
}
}

pub fn argb(&self) -> u32 {
unsafe {
(((self.data.rgba.a as u32) << 24) & 0xFF000000)
| (((self.data.rgba.r as u32) << 16) & 0x00FF0000)
| (((self.data.rgba.g as u32) << 8) & 0x0000FF00)
| ((self.data.rgba.b as u32) & 0x000000FF)
}
}
}
4 changes: 2 additions & 2 deletions omp-gdk/src/types/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ pub enum PeerDisconnectReason {
PeerDisconnectReasonTimeout,
PeerDisconnectReasonQuit,
PeerDisconnectReasonKicked,
// Never used by us, reserved for some existing libraries.
/// Never used, reserved for some existing libraries.
PeerDisconnectReasonCustom,
// 4 to match fixes.inc, which wasn't 3 because some other libraries already used it.
/// to match fixes because some other libraries already used it.
PeerDisconnectReasonModeEnd,
}

0 comments on commit ab749df

Please sign in to comment.