pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}Expand description
A color represented by RGBA components in the [0.0, 1.0] range.
Fields§
§r: f32§g: f32§b: f32§a: f32Implementations§
Source§impl Color
impl Color
pub const BLACK: Color
pub const WHITE: Color
pub const TRANSPARENT: Color
pub const RED: Color
pub const GREEN: Color
pub const BLUE: Color
pub const VIKING_GOLD: Color
pub const MAGENTA_LIQUID: Color
pub const TACTICAL_OBSIDIAN: Color
pub const CYAN: Color
pub const YELLOW: Color
pub const MAGENTA: Color
pub const GRAY: Color
Sourcepub fn relative_luminance(&self) -> f32
pub fn relative_luminance(&self) -> f32
Calculate the relative luminance of the color as defined by WCAG 2.x
Sourcepub fn contrast_ratio(&self, other: &Color) -> f32
pub fn contrast_ratio(&self, other: &Color) -> f32
Calculate the contrast ratio between this color and another color
Trait Implementations§
impl Copy for Color
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
impl StructuralPartialEq for Color
Source§impl View for Color
impl View for Color
Source§type Body = Never
type Body = Never
The concrete type produced after applying modifiers.
For primitive views this is Self.
fn body(self) -> Self::Body
Source§fn render(&self, renderer: &mut dyn Renderer, rect: Rect)
fn render(&self, renderer: &mut dyn Renderer, rect: Rect)
Render this view into the provided renderer at the specified bounds.
Primitive views override this to perform drawing operations.
Source§fn intrinsic_size(
&self,
_renderer: &mut dyn Renderer,
_proposal: SizeProposal,
) -> Size
fn intrinsic_size( &self, _renderer: &mut dyn Renderer, _proposal: SizeProposal, ) -> Size
Calculate the natural (intrinsic) size of this view given proposed constraints.
This allows views like Buttons or Labels to inform the layout engine of their needs.
Source§fn layout(&self) -> Option<&dyn LayoutView>
fn layout(&self) -> Option<&dyn LayoutView>
Optionally provide a layout implementation for this view.
Source§fn flex_weight(&self) -> f32
fn flex_weight(&self) -> f32
Returns the flex weight of this view for proportional distribution in stacks.
Source§fn get_grid_placement(&self) -> Option<GridPlacement>
fn get_grid_placement(&self) -> Option<GridPlacement>
Returns the grid placement configuration for this view if it is laid out in a Grid.
Source§fn modifier<M: ViewModifier>(self, m: M) -> ModifiedView<Self, M>
fn modifier<M: ViewModifier>(self, m: M) -> ModifiedView<Self, M>
Provided modifier entry point
Source§fn bifrost(
self,
blur: f32,
saturation: f32,
opacity: f32,
) -> ModifiedView<Self, BifrostModifier>
fn bifrost( self, blur: f32, saturation: f32, opacity: f32, ) -> ModifiedView<Self, BifrostModifier>
Apply a Bifrost (Frosted Glass) effect to the view
Source§fn gungnir(
self,
color: impl Into<String>,
radius: f32,
intensity: f32,
) -> ModifiedView<Self, GungnirModifier>
fn gungnir( self, color: impl Into<String>, radius: f32, intensity: f32, ) -> ModifiedView<Self, GungnirModifier>
Apply a Gungnir (Neon Glow) effect to the view
Source§fn mjolnir_slice(
self,
angle: f32,
offset: f32,
) -> ModifiedView<Self, MjolnirSliceModifier>
fn mjolnir_slice( self, angle: f32, offset: f32, ) -> ModifiedView<Self, MjolnirSliceModifier>
Apply a Mjolnir Slice (Geometric cut) to the view
Source§fn mjolnir_shatter(
self,
pieces: u32,
force: f32,
) -> ModifiedView<Self, MjolnirShatterModifier>
fn mjolnir_shatter( self, pieces: u32, force: f32, ) -> ModifiedView<Self, MjolnirShatterModifier>
Apply a Mjolnir Shatter (Fragmented transition) to the view
Source§fn bifrost_bridge(
self,
id: impl Into<String>,
) -> ModifiedView<Self, BifrostBridgeModifier>
fn bifrost_bridge( self, id: impl Into<String>, ) -> ModifiedView<Self, BifrostBridgeModifier>
Mark this view as a Bifrost Bridge (Shared Element) for cross-view persistence
Source§fn background(self, color: [f32; 4]) -> ModifiedView<Self, BackgroundModifier>
fn background(self, color: [f32; 4]) -> ModifiedView<Self, BackgroundModifier>
Add a background color to this view
Source§fn padding(self, amount: f32) -> ModifiedView<Self, PaddingModifier>
fn padding(self, amount: f32) -> ModifiedView<Self, PaddingModifier>
Add padding to this view
Source§fn opacity(self, opacity: f32) -> ModifiedView<Self, OpacityModifier>
fn opacity(self, opacity: f32) -> ModifiedView<Self, OpacityModifier>
Set the opacity (alpha) of this view in the range [0.0, 1.0].
Source§fn foreground_color(
self,
color: [f32; 4],
) -> ModifiedView<Self, ForegroundColorModifier>
fn foreground_color( self, color: [f32; 4], ) -> ModifiedView<Self, ForegroundColorModifier>
Override the foreground (text / icon) color of this view.
Source§fn frame(
self,
width: Option<f32>,
height: Option<f32>,
) -> ModifiedView<Self, FrameModifier>
fn frame( self, width: Option<f32>, height: Option<f32>, ) -> ModifiedView<Self, FrameModifier>
Constrain this view to an explicit width and/or height.
Constrains the size of this view using fixed width/height values.
Source§fn flex(self, weight: f32) -> ModifiedView<Self, FlexModifier>
fn flex(self, weight: f32) -> ModifiedView<Self, FlexModifier>
Give this view a flex weight for proportional space distribution in stacks.
Source§fn grid_placement(
self,
placement: GridPlacement,
) -> ModifiedView<Self, GridPlacementModifier>
fn grid_placement( self, placement: GridPlacement, ) -> ModifiedView<Self, GridPlacementModifier>
Specify the grid placement configuration (column, row, column_span, row_span) for this view.
Source§fn overlay<O: View + Clone + 'static>(
self,
overlay: O,
alignment: Alignment,
offset: [f32; 2],
on_dismiss: Option<Arc<dyn Fn() + Send + Sync>>,
) -> ModifiedView<Self, OverlayModifier>
fn overlay<O: View + Clone + 'static>( self, overlay: O, alignment: Alignment, offset: [f32; 2], on_dismiss: Option<Arc<dyn Fn() + Send + Sync>>, ) -> ModifiedView<Self, OverlayModifier>
Overlay a view on top of this view, aligned and offset relative to it.
Source§fn safe_area_padding(self) -> ModifiedView<Self, SafeAreaModifier>
fn safe_area_padding(self) -> ModifiedView<Self, SafeAreaModifier>
Automatically add padding to avoid overlapping with platform safe areas (notches, bars).
Source§fn ignores_safe_area(self) -> ModifiedView<Self, SafeAreaModifier>
fn ignores_safe_area(self) -> ModifiedView<Self, SafeAreaModifier>
Explicitly ignore platform safe areas and draw into the margins.
Source§fn clip_to_bounds(self) -> ModifiedView<Self, ClipModifier>
fn clip_to_bounds(self) -> ModifiedView<Self, ClipModifier>
Clip all child drawing to this view’s bounds.
Source§fn border(
self,
color: [f32; 4],
width: f32,
) -> ModifiedView<Self, BorderModifier>
fn border( self, color: [f32; 4], width: f32, ) -> ModifiedView<Self, BorderModifier>
Draw a colored border around this view.
Source§fn elevation(self, level: f32) -> ModifiedView<Self, ElevationModifier>
fn elevation(self, level: f32) -> ModifiedView<Self, ElevationModifier>
Add elevation (shadow) to the view. Level determines the shadow depth.
Source§fn magnetic(
self,
radius: f32,
intensity: f32,
) -> ModifiedView<Self, MagneticModifier>
fn magnetic( self, radius: f32, intensity: f32, ) -> ModifiedView<Self, MagneticModifier>
Add a magnetic effect that pulls the view towards the cursor.
Source§fn mani_glow(
self,
color: [f32; 4],
radius: f32,
) -> ModifiedView<Self, ManiGlowModifier>
fn mani_glow( self, color: [f32; 4], radius: f32, ) -> ModifiedView<Self, ManiGlowModifier>
Add a ManiGlow (Lunar Illuminator) effect that glows near the cursor.
Source§fn memory_layer(
self,
layer: MemoryLayer,
) -> ModifiedView<Self, BifrostLayerModifier>
fn memory_layer( self, layer: MemoryLayer, ) -> ModifiedView<Self, BifrostLayerModifier>
Theme this view based on a specific memory layer.
Source§fn fafnir_evolve(self, id: u64) -> ModifiedView<Self, FafnirModifier>
fn fafnir_evolve(self, id: u64) -> ModifiedView<Self, FafnirModifier>
Enable Fafnir’s Evolution: The component grows and glows as it is used.
Source§fn mimir_intent(self) -> ModifiedView<Self, MimirIntentModifier>
fn mimir_intent(self) -> ModifiedView<Self, MimirIntentModifier>
Enable Mimir’s Intent: The component anticipates user interaction via pointer kinematics.
Source§fn kvasir_vibes(self, complexity: f32) -> ModifiedView<Self, KvasirVibeModifier>
fn kvasir_vibes(self, complexity: f32) -> ModifiedView<Self, KvasirVibeModifier>
Enable Kvasir’s Vibes: Subconscious telemetry representing cognitive complexity.
Source§fn odins_eye(self) -> ModifiedView<Self, OdinsEyeModifier>
fn odins_eye(self) -> ModifiedView<Self, OdinsEyeModifier>
Bestow Odin’s Eye: Global omniscient observability layer.
Source§fn on_appear<F: Fn() + Send + Sync + 'static>(
self,
action: F,
) -> ModifiedView<Self, LifecycleModifier>
fn on_appear<F: Fn() + Send + Sync + 'static>( self, action: F, ) -> ModifiedView<Self, LifecycleModifier>
Trigger an action when the view appears
Source§fn on_disappear<F: Fn() + Send + Sync + 'static>(
self,
action: F,
) -> ModifiedView<Self, LifecycleModifier>
fn on_disappear<F: Fn() + Send + Sync + 'static>( self, action: F, ) -> ModifiedView<Self, LifecycleModifier>
Trigger an action when the view disappears
Source§fn on_click<F: Fn() + Send + Sync + 'static>(
self,
action: F,
) -> ModifiedView<Self, OnClickModifier>
fn on_click<F: Fn() + Send + Sync + 'static>( self, action: F, ) -> ModifiedView<Self, OnClickModifier>
Trigger an action when the view is clicked
Source§fn on_pointer_enter<F: Fn() + Send + Sync + 'static>(
self,
action: F,
) -> ModifiedView<Self, OnPointerEnterModifier>
fn on_pointer_enter<F: Fn() + Send + Sync + 'static>( self, action: F, ) -> ModifiedView<Self, OnPointerEnterModifier>
Trigger an action when the pointer enters the view bounds
Source§fn on_pointer_leave<F: Fn() + Send + Sync + 'static>(
self,
action: F,
) -> ModifiedView<Self, OnPointerLeaveModifier>
fn on_pointer_leave<F: Fn() + Send + Sync + 'static>( self, action: F, ) -> ModifiedView<Self, OnPointerLeaveModifier>
Trigger an action when the pointer leaves the view bounds
Source§fn on_pointer_move<F: Fn(f32, f32) + Send + Sync + 'static>(
self,
action: F,
) -> ModifiedView<Self, OnPointerMoveModifier>
fn on_pointer_move<F: Fn(f32, f32) + Send + Sync + 'static>( self, action: F, ) -> ModifiedView<Self, OnPointerMoveModifier>
Trigger an action when the pointer moves inside the view bounds
Source§fn on_pointer_down<F: Fn() + Send + Sync + 'static>(
self,
action: F,
) -> ModifiedView<Self, OnPointerDownModifier>
fn on_pointer_down<F: Fn() + Send + Sync + 'static>( self, action: F, ) -> ModifiedView<Self, OnPointerDownModifier>
Trigger an action when the pointer is pressed down
Source§fn on_pointer_up<F: Fn() + Send + Sync + 'static>(
self,
action: F,
) -> ModifiedView<Self, OnPointerUpModifier>
fn on_pointer_up<F: Fn() + Send + Sync + 'static>( self, action: F, ) -> ModifiedView<Self, OnPointerUpModifier>
Trigger an action when the pointer is released
Source§fn aria_properties(&self) -> Option<AriaProperties>
fn aria_properties(&self) -> Option<AriaProperties>
Return accessibility properties for this view.
Override to expose semantic role, label, state to assistive technology.
Default returns
None (view is not explicitly accessible).Source§fn on_key_event(&self, _key: &str, _modifiers: KeyModifiers) -> bool
fn on_key_event(&self, _key: &str, _modifiers: KeyModifiers) -> bool
Handle a keyboard navigation event.
Return true if consumed, false to bubble.
Source§fn key_shortcuts(&self) -> Vec<KeyShortcut>
fn key_shortcuts(&self) -> Vec<KeyShortcut>
Return keyboard shortcuts this view responds to.
Auto Trait Implementations§
impl Freeze for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.