Skip to main content

BorderSide

Struct BorderSide 

Source
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: Color

The color of this side of the border.

§width: f64

The 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: BorderStyle

The 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: f64

The 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

Source

pub const STROKE_ALIGN_INSIDE: f64 = -1.0

The border is drawn fully inside of the border path.

Source

pub const STROKE_ALIGN_CENTER: f64 = 0.0

The border is drawn on the center of the border path.

Source

pub const STROKE_ALIGN_OUTSIDE: f64 = 1.0

The border is drawn on the outside of the border path.

Source

pub const NONE: BorderSide

A hairline black border that is not rendered.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn lerp(a: BorderSide, b: BorderSide, t: f64) -> BorderSide

Linearly interpolate between two border sides.

Source

pub fn stroke_inset(&self) -> f64

Get the amount of the stroke width that lies inside of the BorderSide.

Source

pub fn stroke_outset(&self) -> f64

Get the amount of the stroke width that lies outside of the BorderSide.

Source

pub fn stroke_offset(&self) -> f64

The offset of the stroke, taking into account the stroke alignment.

Trait Implementations§

Source§

impl Clone for BorderSide

Source§

fn clone(&self) -> BorderSide

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 Copy for BorderSide

Source§

impl Debug for BorderSide

Source§

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

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

impl Default for BorderSide

Source§

fn default() -> BorderSide

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

impl Diagnosticable for BorderSide

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 BorderSide

Dart’s BorderSide.toString, which Debug already renders.

Source§

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

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

impl From<BorderSide> for AnyBorderSide

Source§

fn from(value: BorderSide) -> AnyBorderSide

Converts to this type from the input type.
Source§

impl PartialEq for BorderSide

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for BorderSide

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>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,