Skip to main content

ShapeDecoration

Struct ShapeDecoration 

Source
pub struct ShapeDecoration {
    pub color: Option<AnyColor>,
    pub gradient: Option<GradientRef>,
    pub shadows: Option<Vec<BoxShadow>>,
    pub shape: ShapeBorderRef,
}
Expand description

An immutable description of how to paint an arbitrary shape.

ShapeDecoration draws a [ShapeBorder], optionally filling it with a color or a gradient and optionally casting a shadow.

image is deferred (see PORTING.md).

Fields§

§color: Option<AnyColor>

The color to fill in the background of the shape.

The color is under the image (image paint is deferred).

If a gradient is specified, color must be None.

§gradient: Option<GradientRef>

A gradient to use when filling the shape.

The gradient is under the image (image paint is deferred).

If a color is specified, gradient must be None.

§shadows: Option<Vec<BoxShadow>>

A list of shadows cast by the shape.

§shape: ShapeBorderRef

The shape to fill the color and gradient into and to cast as the shadows.

Shapes can be stacked (using plus). The color and gradient are drawn into the inner-most shape specified.

The shape property specifies the outline (border) of the decoration.

Implementations§

Source§

impl ShapeDecoration

Source

pub fn new(shape: impl Into<ShapeBorderRef>) -> ShapeDecoration

Creates a shape decoration.

shape is required. Chain setters for the fields Dart’s constructor takes as named arguments: ShapeDecoration::new(shape).color(c).

  • If color is None, this decoration does not paint a background color.
  • If gradient is None, this decoration does not paint gradients.
  • If shadows is None, this decoration does not paint a shadow.

The color and gradient properties are mutually exclusive, one (or both) of them must be None.

Source

pub fn color(self, color: impl Into<AnyColor>) -> ShapeDecoration

The color to fill in the background of the shape.

Source

pub fn gradient(self, gradient: impl Into<GradientRef>) -> ShapeDecoration

A gradient to use when filling the shape.

Source

pub fn shadows(self, shadows: Vec<BoxShadow>) -> ShapeDecoration

A list of shadows cast by the shape.

Source

pub fn shape(self, shape: impl Into<ShapeBorderRef>) -> ShapeDecoration

The shape to fill and to cast as the shadows.

Source

pub fn from_box_decoration(source: &BoxDecoration) -> ShapeDecoration

Creates a shape decoration configured to match a BoxDecoration.

Source

pub fn copy_with(&self) -> ShapeDecoration

Creates a copy of this object. Chain setters to replace fields (decoration.copy_with().color(c)).

Source

pub fn lerp( a: Option<&ShapeDecoration>, b: Option<&ShapeDecoration>, t: f64, ) -> Option<ShapeDecoration>

Linearly interpolate between two shapes.

Interpolates each parameter of the decoration separately.

If both values are None, this returns None. Otherwise, it returns a non-null value, with null arguments treated like a ShapeDecoration whose optional fields are all None.

Trait Implementations§

Source§

impl Clone for ShapeDecoration

Source§

fn clone(&self) -> ShapeDecoration

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ShapeDecoration

Source§

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

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

impl Decoration for ShapeDecoration

Source§

fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)

Dart’s Decoration.debugFillProperties, inherited from Diagnosticable: a subclass adds its own properties and calls this first, as Dart’s super does.
Source§

fn padding(&self) -> EdgeInsetsGeometry

Returns the insets to apply when using this decoration on a box that has contents, so that the contents do not overlap the edges of the decoration.
Source§

fn is_complex(&self) -> bool

Whether this decoration is complex enough to benefit from caching its painting.
Source§

fn lerp_from( &self, a: Option<&(dyn Decoration + 'static)>, t: f64, ) -> Option<DecorationRef>

Linearly interpolates from another Decoration (which may be of a different class) to this. Read more
Source§

fn lerp_to( &self, b: Option<&(dyn Decoration + 'static)>, t: f64, ) -> Option<DecorationRef>

Linearly interpolates from this to another Decoration (which may be of a different class).
Source§

fn hit_test( &self, size: Size, position: Offset, text_direction: Option<TextDirection>, ) -> bool

Tests whether the given point, on a rectangle of a given size, would be considered to hit the decoration or not.
Source§

fn create_box_painter( &self, on_changed: Option<Rc<dyn Fn(&mut App)>>, ) -> Box<dyn BoxPainter>

Returns a BoxPainter that will paint this decoration.
Source§

fn get_clip_path(&self, rect: Rect, text_direction: TextDirection) -> Path

Returns a closed Path that describes the outer edge of this decoration. Read more
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Downcast support for is / as in Dart.
Source§

fn eq_decoration(&self, other: &(dyn Decoration + 'static)) -> bool

Field equality. Dart’s default == is identity; subclasses that override == implement this.
Source§

fn diagnostics_node(&self, name: Option<String>) -> DiagnosticableNode

Dart’s Decoration.toDiagnosticsNode(name:), inherited from Diagnosticable; a dyn Decoration cannot name the Sized Diagnosticable, so the bridge lives here.
Source§

fn to_string_short(&self) -> String

Dart’s Decoration.toStringShort: the runtime type.
Source§

fn debug_assert_is_valid(&self) -> bool

In debug mode, panics if the object is not in a valid configuration. Otherwise, returns true.
Source§

impl Diagnosticable for ShapeDecoration

Source§

fn to_string_short(&self) -> String

A brief description of this object, usually just the type and the hash.
Source§

fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)

Add additional properties associated with the node.
Source§

fn type_name(&self) -> &'static str

Dart’s Object.runtimeType as diagnostics print it: the last segment of the Rust type path, without generic arguments.
Source§

fn identity_hash(&self) -> u64

Dart’s Object.hashCode as diagnostics print it: the object’s address.
Source§

fn to_diagnostics_node(&self) -> DiagnosticableNode

Returns a debug representation of the object used by debugging tools and by DiagnosticsNode::to_string_deep.
Source§

fn to_diagnostics_node_with( &self, name: Option<String>, style: Option<DiagnosticsTreeStyle>, ) -> DiagnosticableNode

Dart toDiagnosticsNode(name:, style:).
Source§

fn to_string(&self) -> String

Dart’s toString: a single-line description with properties and no children. Read more
Source§

fn to_string_at(&self, min_level: DiagnosticLevel) -> String

Dart’s toString(minLevel:).
Source§

impl Display for ShapeDecoration

Source§

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

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

impl PartialEq for ShapeDecoration

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>