pub struct RectShape {
pub rect: Rect,
pub corner_radius: CornerRadius,
pub fill: Color32,
pub stroke: Stroke,
pub stroke_kind: StrokeKind,
pub round_to_pixels: Option<bool>,
pub blur_width: f32,
pub brush: Option<Arc<Brush>>,
}Expand description
How to paint a rectangle.
Fields§
§rect: Rect§corner_radius: CornerRadiusHow rounded the corners of the rectangle are.
Use CornerRadius::ZERO for for sharp corners.
This is the corner radii of the rectangle.
If there is a stroke, then the stroke will have an inner and outer corner radius,
and those will depend on StrokeKind and the stroke width.
For StrokeKind::Inside, the outside of the stroke coincides with the rectangle,
so the rounding will in this case specify the outer corner radius.
fill: Color32How to fill the rectangle.
stroke: StrokeThe thickness and color of the outline.
Whether or not the stroke is inside or outside the edge of Self::rect,
is controlled by Self::stroke_kind.
stroke_kind: StrokeKindIs the stroke on the inside, outside, or centered on the rectangle?
If you want to perfectly tile rectangles, use StrokeKind::Inside.
round_to_pixels: Option<bool>Snap the rectangle to pixels?
Rounding produces sharper rectangles.
If None, crate::TessellationOptions::round_rects_to_pixels will be used.
blur_width: f32If larger than zero, the edges of the rectangle (for both fill and stroke) will be blurred.
This can be used to produce shadows and glow effects.
The blur is currently implemented using a simple linear blur in sRGBA gamma space.
brush: Option<Arc<Brush>>Controls texturing, if any.
Since most rectangles do not have a texture, this is optional and in an Arc,
so that RectShape is kept small..
Implementations§
Source§impl RectShape
impl RectShape
Sourcepub fn new(
rect: Rect,
corner_radius: impl Into<CornerRadius>,
fill_color: impl Into<Color32>,
stroke: impl Into<Stroke>,
stroke_kind: StrokeKind,
) -> RectShape
pub fn new( rect: Rect, corner_radius: impl Into<CornerRadius>, fill_color: impl Into<Color32>, stroke: impl Into<Stroke>, stroke_kind: StrokeKind, ) -> RectShape
See also Self::filled and Self::stroke.
pub fn filled( rect: Rect, corner_radius: impl Into<CornerRadius>, fill_color: impl Into<Color32>, ) -> RectShape
pub fn stroke( rect: Rect, corner_radius: impl Into<CornerRadius>, stroke: impl Into<Stroke>, stroke_kind: StrokeKind, ) -> RectShape
Sourcepub fn with_stroke_kind(self, stroke_kind: StrokeKind) -> RectShape
pub fn with_stroke_kind(self, stroke_kind: StrokeKind) -> RectShape
Set if the stroke is on the inside, outside, or centered on the rectangle.
Sourcepub fn with_round_to_pixels(self, round_to_pixels: bool) -> RectShape
pub fn with_round_to_pixels(self, round_to_pixels: bool) -> RectShape
Snap the rectangle to pixels?
Rounding produces sharper rectangles.
If None, crate::TessellationOptions::round_rects_to_pixels will be used.
Sourcepub fn with_blur_width(self, blur_width: f32) -> RectShape
pub fn with_blur_width(self, blur_width: f32) -> RectShape
If larger than zero, the edges of the rectangle (for both fill and stroke) will be blurred.
This can be used to produce shadows and glow effects.
The blur is currently implemented using a simple linear blur in sRGBA gamma space.
Sourcepub fn with_texture(self, fill_texture_id: TextureId, uv: Rect) -> RectShape
pub fn with_texture(self, fill_texture_id: TextureId, uv: Rect) -> RectShape
Set the texture to use when painting this rectangle, if any.
Sourcepub fn visual_bounding_rect(&self) -> Rect
pub fn visual_bounding_rect(&self) -> Rect
The visual bounding rectangle (includes stroke width)
Sourcepub fn fill_texture_id(&self) -> TextureId
pub fn fill_texture_id(&self) -> TextureId
The texture to use when painting this rectangle, if any.
If no texture is set, this will return TextureId::default.
Trait Implementations§
impl StructuralPartialEq for RectShape
Auto Trait Implementations§
impl Freeze for RectShape
impl RefUnwindSafe for RectShape
impl Send for RectShape
impl Sync for RectShape
impl Unpin for RectShape
impl UnwindSafe for RectShape
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FilterHaving<T, Here> for Twhere
T: ?Sized,
impl<T> FilterHaving<T, Here> for Twhere
T: ?Sized,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more