Enum i_slint_core::Brush
source · #[non_exhaustive]#[repr(C)]pub enum Brush {
SolidColor(Color),
LinearGradient(LinearGradientBrush),
RadialGradient(RadialGradientBrush),
}
Expand description
A brush is a data structure that is used to describe how a shape, such as a rectangle, path or even text, shall be filled. A brush can also be applied to the outline of a shape, that means the fill of the outline itself.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
SolidColor(Color)
The color variant of brush is a plain color that is to be used for the fill.
LinearGradient(LinearGradientBrush)
The linear gradient variant of a brush describes the gradient stops for a fill where all color stops are along a line that’s rotated by the specified angle.
RadialGradient(RadialGradientBrush)
The radial gradient variant of a brush describes a circle variant centered in the middle
Implementations§
source§impl Brush
impl Brush
sourcepub fn color(&self) -> Color
pub fn color(&self) -> Color
If the brush is SolidColor, the contained color is returned. If the brush is a LinearGradient, the color of the first stop is returned.
sourcepub fn is_transparent(&self) -> bool
pub fn is_transparent(&self) -> bool
Returns true if this brush contains a fully transparent color (alpha value is zero)
assert!(Brush::default().is_transparent());
assert!(Brush::SolidColor(Color::from_argb_u8(0, 255, 128, 140)).is_transparent());
assert!(!Brush::SolidColor(Color::from_argb_u8(25, 128, 140, 210)).is_transparent());
sourcepub fn is_opaque(&self) -> bool
pub fn is_opaque(&self) -> bool
Returns true if this brush is fully opaque
assert!(!Brush::default().is_opaque());
assert!(!Brush::SolidColor(Color::from_argb_u8(25, 255, 128, 140)).is_opaque());
assert!(Brush::SolidColor(Color::from_rgb_u8(128, 140, 210)).is_opaque());
sourcepub fn brighter(&self, factor: f32) -> Self
pub fn brighter(&self, factor: f32) -> Self
Returns a new version of this brush that has the brightness increased
by the specified factor. This is done by calling Color::brighter
on
all the colors of this brush.
sourcepub fn darker(&self, factor: f32) -> Self
pub fn darker(&self, factor: f32) -> Self
Returns a new version of this brush that has the brightness decreased
by the specified factor. This is done by calling Color::darker
on
all the color of this brush.
sourcepub fn transparentize(&self, amount: f32) -> Self
pub fn transparentize(&self, amount: f32) -> Self
Returns a new version of this brush with the opacity decreased by factor
.
The transparency is obtained by multiplying the alpha channel by (1 - factor)
.
See also Color::transparentize
sourcepub fn with_alpha(&self, alpha: f32) -> Self
pub fn with_alpha(&self, alpha: f32) -> Self
Returns a new version of this brush with the related color’s opacities
set to alpha
.
Trait Implementations§
source§impl From<LinearGradientBrush> for Brush
impl From<LinearGradientBrush> for Brush
source§fn from(original: LinearGradientBrush) -> Brush
fn from(original: LinearGradientBrush) -> Brush
source§impl From<RadialGradientBrush> for Brush
impl From<RadialGradientBrush> for Brush
source§fn from(original: RadialGradientBrush) -> Brush
fn from(original: RadialGradientBrush) -> Brush
source§impl InterpolatedPropertyValue for Brush
impl InterpolatedPropertyValue for Brush
source§fn interpolate(&self, target_value: &Self, t: f32) -> Self
fn interpolate(&self, target_value: &Self, t: f32) -> Self
impl StructuralPartialEq for Brush
Auto Trait Implementations§
impl Freeze for Brush
impl RefUnwindSafe for Brush
impl Send for Brush
impl !Sync for Brush
impl Unpin for Brush
impl UnwindSafe for Brush
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)