pub struct Color(/* private fields */);Expand description
A color stored in BGR format, matching the HWP binary specification.
Internally a u32 with repr(transparent) for zero overhead.
FROZEN: Do not change the internal representation after v1.0.
§Layout
Bits: [31..24 reserved] [23..16 blue] [15..8 green] [7..0 red]§Examples
use hwpforge_foundation::Color;
let c = Color::from_rgb(0x11, 0x22, 0x33);
assert_eq!(c.to_raw(), 0x00332211);
assert_eq!(c.to_string(), "#112233");Implementations§
Source§impl Color
impl Color
Sourcepub fn to_hex_rgb(&self) -> String
pub fn to_hex_rgb(&self) -> String
Converts this color to an RGB hex string in #RRGGBB format.
Since HWP uses BGR byte order internally, this method swaps the bytes to produce standard RGB hex output.
§Examples
use hwpforge_foundation::Color;
let red = Color::from_rgb(255, 0, 0);
assert_eq!(red.to_hex_rgb(), "#FF0000");Trait Implementations§
Source§impl<'de> Deserialize<'de> for Color
impl<'de> Deserialize<'de> for Color
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl JsonSchema for Color
impl JsonSchema for Color
Source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreimpl Copy for Color
impl Eq for Color
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl Freeze for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnwindSafe for Color
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.