i_slint_core

Enum 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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

Source

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.

Source

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());
Source

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());
Source

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.

Source

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.

Source

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

Source

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 Clone for Brush

Source§

fn clone(&self) -> Brush

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Brush

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Brush

Construct a brush with transparent color

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<Color> for Brush

Source§

fn from(value: Color) -> Self

Converts to this type from the input type.
Source§

impl From<LinearGradientBrush> for Brush

Source§

fn from(value: LinearGradientBrush) -> Self

Converts to this type from the input type.
Source§

impl From<RadialGradientBrush> for Brush

Source§

fn from(value: RadialGradientBrush) -> Self

Converts to this type from the input type.
Source§

impl InterpolatedPropertyValue for Brush

Source§

fn interpolate(&self, target_value: &Self, t: f32) -> Self

Returns the interpolated value between self and target_value according to the progress parameter t that’s usually between 0 and 1. With certain animation easing curves it may over- or undershoot though.
Source§

impl PartialEq for Brush

Source§

fn eq(&self, other: &Brush) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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 T
where 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.