diff --git a/editor/src/messages/input_mapper/utility_types/input_keyboard.rs b/editor/src/messages/input_mapper/utility_types/input_keyboard.rs index b6a2424c52..041edb4ca0 100644 --- a/editor/src/messages/input_mapper/utility_types/input_keyboard.rs +++ b/editor/src/messages/input_mapper/utility_types/input_keyboard.rs @@ -16,7 +16,6 @@ pub type StorageType = u128; // KeyStates // ========= -// Base-2 logarithm of the storage type used to represents how many bits you need to fully address every bit in that storage type const STORAGE_SIZE: u32 = (std::mem::size_of::() * 8).trailing_zeros(); const STORAGE_SIZE_BITS: usize = 1 << STORAGE_SIZE; const KEY_MASK_STORAGE_LENGTH: usize = (NUMBER_OF_KEYS + STORAGE_SIZE_BITS - 1) >> STORAGE_SIZE; diff --git a/node-graph/libraries/no-std-types/src/color/color_types.rs b/node-graph/libraries/no-std-types/src/color/color_types.rs index 2847097416..56ba5d958e 100644 --- a/node-graph/libraries/no-std-types/src/color/color_types.rs +++ b/node-graph/libraries/no-std-types/src/color/color_types.rs @@ -254,10 +254,6 @@ impl RGB for Luma { impl Pixel for Luma {} -/// Structure that represents a color. -/// Internally alpha is stored as `f32` that ranges from `0.` (transparent) to `1.` (opaque). -/// The other components (RGB) are stored as `f32` that range from `0.` up to `f32::MAX`, -/// the values encode the brightness of each channel proportional to the light intensity in cd/m² (nits) in HDR, and `0.` (black) to `1.` (white) in SDR color. /// Linear-light sRGB color with `f32` channels (alpha unassociated for swatch/UI colors, associated/premultiplied for pixel data inside [`Image`]). /// /// Channels range from `0.` to `f32::MAX`, encoding brightness proportional to light intensity (cd/m² nits in HDR, or `0..=1` mapped to white for SDR). @@ -424,18 +420,7 @@ impl Color { alpha: 0., }; - /// Returns `Some(Color)` if `red`, `green`, `blue` and `alpha` have a valid value. Negative numbers (including `-0.`), NaN, and infinity are not valid values and return `None`. - /// Alpha values greater than `1.` are not valid. - /// - /// # Examples - /// ``` - /// use core_types::color::Color; - /// let color = Color::from_rgbaf32(0.3, 0.14, 0.15, 0.92).unwrap(); - /// assert!(color.components() == (0.3, 0.14, 0.15, 0.92)); - /// - /// let color = Color::from_rgbaf32(1., 1., 1., f32::NAN); - /// assert!(color == None); - /// ``` + /// Builds a color from linear-light `f32` channels, returning `None` if any channel is negative, NaN, or infinite, or if `alpha` exceeds `1.`. #[inline(always)] pub fn from_rgbaf32(red: f32, green: f32, blue: f32, alpha: f32) -> Option { if alpha > 1. || [red, green, blue, alpha].iter().any(|c| c.is_sign_negative() || !c.is_finite()) { @@ -526,53 +511,25 @@ impl Color { Color::from_gamma_srgb_channels(red, green, blue, alpha) } - /// Return the `red` component. - /// - /// # Examples - /// ``` - /// use core_types::color::Color; - /// let color = Color::from_rgbaf32(0.114, 0.103, 0.98, 0.97).unwrap(); - /// assert!(color.r() == 0.114); - /// ``` + /// The red channel value. #[inline(always)] pub fn r(&self) -> f32 { self.red } - /// Return the `green` component. - /// - /// # Examples - /// ``` - /// use core_types::color::Color; - /// let color = Color::from_rgbaf32(0.114, 0.103, 0.98, 0.97).unwrap(); - /// assert!(color.g() == 0.103); - /// ``` + /// The green channel value. #[inline(always)] pub fn g(&self) -> f32 { self.green } - /// Return the `blue` component. - /// - /// # Examples - /// ``` - /// use core_types::color::Color; - /// let color = Color::from_rgbaf32(0.114, 0.103, 0.98, 0.97).unwrap(); - /// assert!(color.b() == 0.98); - /// ``` + /// The blue channel value. #[inline(always)] pub fn b(&self) -> f32 { self.blue } - /// Return the `alpha` component without checking its expected `0.` to `1.` range. - /// - /// # Examples - /// ``` - /// use core_types::color::Color; - /// let color = Color::from_rgbaf32(0.114, 0.103, 0.98, 0.97).unwrap(); - /// assert!(color.a() == 0.97); - /// ``` + /// The alpha channel value, returned as-is without range checking. #[inline(always)] pub fn a(&self) -> f32 { self.alpha @@ -882,14 +839,7 @@ impl Color { self.with_luminance(lum_s) } - /// Return the all components as a tuple, first component is red, followed by green, followed by blue, followed by alpha. - /// - /// # Examples - /// ``` - /// use core_types::color::Color; - /// let color = Color::from_rgbaf32(0.114, 0.103, 0.98, 0.97).unwrap(); - /// assert_eq!(color.components(), (0.114, 0.103, 0.98, 0.97)); - /// ``` + /// All four channels as `(red, green, blue, alpha)`. #[inline(always)] pub fn components(&self) -> (f32, f32, f32, f32) { (self.red, self.green, self.blue, self.alpha)