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).
gradient: Option<GradientRef>A gradient to use when filling the shape.
The gradient is under the image (image paint is deferred).
shadows: Option<Vec<BoxShadow>>A list of shadows cast by the shape.
shape: ShapeBorderRefThe 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
impl ShapeDecoration
Sourcepub fn new(shape: impl Into<ShapeBorderRef>) -> ShapeDecoration
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
coloris None, this decoration does not paint a background color. - If
gradientis None, this decoration does not paint gradients. - If
shadowsis None, this decoration does not paint a shadow.
The color and gradient properties are mutually
exclusive, one (or both) of them must be None.
Sourcepub fn color(self, color: impl Into<AnyColor>) -> ShapeDecoration
pub fn color(self, color: impl Into<AnyColor>) -> ShapeDecoration
The color to fill in the background of the shape.
Sourcepub fn gradient(self, gradient: impl Into<GradientRef>) -> ShapeDecoration
pub fn gradient(self, gradient: impl Into<GradientRef>) -> ShapeDecoration
A gradient to use when filling the shape.
Sourcepub fn shadows(self, shadows: Vec<BoxShadow>) -> ShapeDecoration
pub fn shadows(self, shadows: Vec<BoxShadow>) -> ShapeDecoration
A list of shadows cast by the shape.
Sourcepub fn shape(self, shape: impl Into<ShapeBorderRef>) -> ShapeDecoration
pub fn shape(self, shape: impl Into<ShapeBorderRef>) -> ShapeDecoration
The shape to fill and to cast as the shadows.
Sourcepub fn from_box_decoration(source: &BoxDecoration) -> ShapeDecoration
pub fn from_box_decoration(source: &BoxDecoration) -> ShapeDecoration
Creates a shape decoration configured to match a BoxDecoration.
Sourcepub fn copy_with(&self) -> ShapeDecoration
pub fn copy_with(&self) -> ShapeDecoration
Creates a copy of this object. Chain setters to replace fields
(decoration.copy_with().color(c)).
Sourcepub fn lerp(
a: Option<&ShapeDecoration>,
b: Option<&ShapeDecoration>,
t: f64,
) -> Option<ShapeDecoration>
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
impl Clone for ShapeDecoration
Source§fn clone(&self) -> ShapeDecoration
fn clone(&self) -> ShapeDecoration
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ShapeDecoration
impl Debug for ShapeDecoration
Source§impl Decoration for ShapeDecoration
impl Decoration for ShapeDecoration
Source§fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
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
fn padding(&self) -> EdgeInsetsGeometry
Source§fn is_complex(&self) -> bool
fn is_complex(&self) -> bool
Source§fn lerp_from(
&self,
a: Option<&(dyn Decoration + 'static)>,
t: f64,
) -> Option<DecorationRef>
fn lerp_from( &self, a: Option<&(dyn Decoration + 'static)>, t: f64, ) -> Option<DecorationRef>
Decoration (which may be of a
different class) to this. Read moreSource§fn lerp_to(
&self,
b: Option<&(dyn Decoration + 'static)>,
t: f64,
) -> Option<DecorationRef>
fn lerp_to( &self, b: Option<&(dyn Decoration + 'static)>, t: f64, ) -> Option<DecorationRef>
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
fn hit_test( &self, size: Size, position: Offset, text_direction: Option<TextDirection>, ) -> bool
Source§fn create_box_painter(
&self,
on_changed: Option<Rc<dyn Fn(&mut App)>>,
) -> Box<dyn BoxPainter>
fn create_box_painter( &self, on_changed: Option<Rc<dyn Fn(&mut App)>>, ) -> Box<dyn BoxPainter>
BoxPainter that will paint this decoration.Source§fn get_clip_path(&self, rect: Rect, text_direction: TextDirection) -> Path
fn get_clip_path(&self, rect: Rect, text_direction: TextDirection) -> Path
Source§fn eq_decoration(&self, other: &(dyn Decoration + 'static)) -> bool
fn eq_decoration(&self, other: &(dyn Decoration + 'static)) -> bool
== is identity; subclasses that override
== implement this.Source§fn diagnostics_node(&self, name: Option<String>) -> DiagnosticableNode
fn diagnostics_node(&self, name: Option<String>) -> DiagnosticableNode
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
fn to_string_short(&self) -> String
Decoration.toStringShort: the runtime type.Source§fn debug_assert_is_valid(&self) -> bool
fn debug_assert_is_valid(&self) -> bool
Source§impl Diagnosticable for ShapeDecoration
impl Diagnosticable for ShapeDecoration
Source§fn to_string_short(&self) -> String
fn to_string_short(&self) -> String
Source§fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Object.runtimeType as diagnostics print it: the last segment of
the Rust type path, without generic arguments.Source§fn identity_hash(&self) -> u64
fn identity_hash(&self) -> u64
Object.hashCode as diagnostics print it: the object’s address.Source§fn to_diagnostics_node(&self) -> DiagnosticableNode
fn to_diagnostics_node(&self) -> DiagnosticableNode
DiagnosticsNode::to_string_deep.Source§fn to_diagnostics_node_with(
&self,
name: Option<String>,
style: Option<DiagnosticsTreeStyle>,
) -> DiagnosticableNode
fn to_diagnostics_node_with( &self, name: Option<String>, style: Option<DiagnosticsTreeStyle>, ) -> DiagnosticableNode
toDiagnosticsNode(name:, style:).Source§fn to_string(&self) -> String
fn to_string(&self) -> String
toString: a single-line description with properties and no
children. Read moreSource§fn to_string_at(&self, min_level: DiagnosticLevel) -> String
fn to_string_at(&self, min_level: DiagnosticLevel) -> String
toString(minLevel:).