pub struct HighColor {
    pub red: u8,
    pub green: u8,
    pub blue: u8,
}
Expand description

reg.udral.physics.optics.HighColor.0.1

Fixed size 2 bytes

Color in the standard 16-bit 5-6-5 RGB format (green is wider due to non-uniform color sensitivity of the human eye). https://en.wikipedia.org/wiki/High_color

For reasons of unification, a monochrome light can be modeled using the same type, where the brightness is defined as the mean of the color components normalized to one:

brightness = (red/MAX_RED + green/MAX_GREEN + blue/MAX_BLUE) / 3

Fields§

§red: u8

saturated uint5

Always aligned, size 5 bits

§green: u8

saturated uint6

Not always aligned, size 6 bits

§blue: u8

saturated uint5

Not always aligned, size 5 bits

Implementations§

source§

impl HighColor

source

pub const MAX_RED: u8 = 31u8

source

pub const MAX_GREEN: u8 = 63u8

source

pub const MAX_BLUE: u8 = 31u8

Trait Implementations§

source§

impl DataType for HighColor

source§

const EXTENT_BYTES: Option<u32> = None

This type is sealed.

source§

impl Deserialize for HighColor

source§

fn deserialize(cursor: &mut ReadCursor<'_>) -> Result<Self, DeserializeError>where Self: Sized,

Deserializes a value and returns it
source§

fn deserialize_from_bytes(bytes: &[u8]) -> Result<Self, DeserializeError>where Self: Sized,

A convenience function that creates a cursor around the provided bytes and calls deserialize
source§

impl Serialize for HighColor

source§

fn size_bits(&self) -> usize

Returns the size of the encoded form of this value, in bits Read more
source§

fn serialize(&self, cursor: &mut WriteCursor<'_>)

Serializes this value into a buffer Read more
source§

fn serialize_to_bytes(&self, bytes: &mut [u8])

A convenience function that creates a cursor around the provided bytes and calls serialize
source§

impl Message for HighColor

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.