pub struct BorderSide {
pub color: Color,
pub width: f64,
pub style: BorderStyle,
pub stroke_align: f64,
}Expand description
A side of a border of a box.
A Border consists of four BorderSide objects.
Setting width to 0.0 will result in hairline rendering;
see width for a more involved explanation.
Fields§
§color: ColorThe color of this side of the border.
width: f64The width of this side of the border, in logical pixels.
Setting width to 0.0 will result in a hairline border. This means that the border will have the width of one physical pixel. Hairline rendering takes shortcuts when the path overlaps a pixel more than once. This means that it will render faster than otherwise, but it might double-hit pixels, giving it a slightly darker/lighter result.
To omit the border entirely, set the style to
BorderStyle::None.
style: BorderStyleThe style of this side of the border.
To omit a side, set style to BorderStyle::None.
This skips painting the border, but the border still has a
width.
stroke_align: f64The relative position of the stroke on a BorderSide in an
OutlinedBorder or Border.
Values typically range from -1.0 (STROKE_ALIGN_INSIDE, inside border,
default) to 1.0 (STROKE_ALIGN_OUTSIDE, outside border), without any
bound constraints. A value of 0 (STROKE_ALIGN_CENTER) will center the
border on the edge of the widget.
This property is not honored by to_paint (because the
Paint object cannot represent it); it is intended that classes that
use BorderSide objects implement this property when painting borders
by suitably inflating or deflating their regions.
Implementations§
Source§impl BorderSide
impl BorderSide
Sourcepub const STROKE_ALIGN_INSIDE: f64 = -1.0
pub const STROKE_ALIGN_INSIDE: f64 = -1.0
The border is drawn fully inside of the border path.
Sourcepub const STROKE_ALIGN_CENTER: f64 = 0.0
pub const STROKE_ALIGN_CENTER: f64 = 0.0
The border is drawn on the center of the border path.
Sourcepub const STROKE_ALIGN_OUTSIDE: f64 = 1.0
pub const STROKE_ALIGN_OUTSIDE: f64 = 1.0
The border is drawn on the outside of the border path.
Sourcepub const NONE: BorderSide
pub const NONE: BorderSide
A hairline black border that is not rendered.
Sourcepub fn new(
color: Color,
width: f64,
style: BorderStyle,
stroke_align: f64,
) -> BorderSide
pub fn new( color: Color, width: f64, style: BorderStyle, stroke_align: f64, ) -> BorderSide
Creates the side of a border.
By default, the border is 1.0 logical pixels wide and solid black.
Sourcepub fn merge(a: BorderSide, b: BorderSide) -> BorderSide
pub fn merge(a: BorderSide, b: BorderSide) -> BorderSide
Creates a BorderSide that represents the addition of the two given
BorderSides.
It is only valid to call this if can_merge returns
true for the two sides.
If one of the sides is zero-width with BorderStyle::None, then the
other side is returned as-is. If both of the sides are zero-width with
BorderStyle::None, then BorderSide::NONE is returned.
Sourcepub fn copy_with(
&self,
color: Option<Color>,
width: Option<f64>,
style: Option<BorderStyle>,
stroke_align: Option<f64>,
) -> BorderSide
pub fn copy_with( &self, color: Option<Color>, width: Option<f64>, style: Option<BorderStyle>, stroke_align: Option<f64>, ) -> BorderSide
Creates a copy of this border but with the given fields replaced with the new values.
Sourcepub fn scale(&self, t: f64) -> BorderSide
pub fn scale(&self, t: f64) -> BorderSide
Creates a copy of this border side description but with the width scaled
by the factor t.
Since a zero width is normally painted as a hairline width rather than no
border at all, the zero factor is special-cased to instead change the
style to BorderStyle::None.
Negative values are treated like zero.
Sourcepub fn to_paint(&self) -> Paint
pub fn to_paint(&self) -> Paint
Create a Paint object that, if used to stroke a line, will draw the
line in this border’s style.
The stroke_align property is not reflected in the
Paint; consumers must implement that directly by inflating or
deflating their region appropriately.
Sourcepub fn can_merge(a: BorderSide, b: BorderSide) -> bool
pub fn can_merge(a: BorderSide, b: BorderSide) -> bool
Whether the two given BorderSides can be merged using merge.
Two sides can be merged if one or both are zero-width with
BorderStyle::None, or if they both have the same color and style.
Sourcepub fn lerp(a: BorderSide, b: BorderSide, t: f64) -> BorderSide
pub fn lerp(a: BorderSide, b: BorderSide, t: f64) -> BorderSide
Linearly interpolate between two border sides.
Sourcepub fn stroke_inset(&self) -> f64
pub fn stroke_inset(&self) -> f64
Get the amount of the stroke width that lies inside of the BorderSide.
Sourcepub fn stroke_outset(&self) -> f64
pub fn stroke_outset(&self) -> f64
Get the amount of the stroke width that lies outside of the BorderSide.
Sourcepub fn stroke_offset(&self) -> f64
pub fn stroke_offset(&self) -> f64
The offset of the stroke, taking into account the stroke alignment.
Trait Implementations§
Source§impl Clone for BorderSide
impl Clone for BorderSide
Source§fn clone(&self) -> BorderSide
fn clone(&self) -> BorderSide
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for BorderSide
Source§impl Debug for BorderSide
impl Debug for BorderSide
Source§impl Default for BorderSide
impl Default for BorderSide
Source§fn default() -> BorderSide
fn default() -> BorderSide
Source§impl Diagnosticable for BorderSide
impl Diagnosticable for BorderSide
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:).Source§impl Display for BorderSide
Dart’s BorderSide.toString, which Debug already renders.
impl Display for BorderSide
Dart’s BorderSide.toString, which Debug already renders.