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: CornerRadius
How 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: Color32
How to fill the rectangle.
stroke: Stroke
The 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: StrokeKind
Is 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: f32
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.
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,
) -> Self
pub fn new( rect: Rect, corner_radius: impl Into<CornerRadius>, fill_color: impl Into<Color32>, stroke: impl Into<Stroke>, stroke_kind: StrokeKind, ) -> Self
See also Self::filled
and Self::stroke
.
pub fn filled( rect: Rect, corner_radius: impl Into<CornerRadius>, fill_color: impl Into<Color32>, ) -> Self
pub fn stroke( rect: Rect, corner_radius: impl Into<CornerRadius>, stroke: impl Into<Stroke>, stroke_kind: StrokeKind, ) -> Self
Sourcepub fn with_stroke_kind(self, stroke_kind: StrokeKind) -> Self
pub fn with_stroke_kind(self, stroke_kind: StrokeKind) -> Self
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) -> Self
pub fn with_round_to_pixels(self, round_to_pixels: bool) -> Self
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) -> Self
pub fn with_blur_width(self, blur_width: f32) -> Self
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) -> Self
pub fn with_texture(self, fill_texture_id: TextureId, uv: Rect) -> Self
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§
Source§impl<'de> Deserialize<'de> for RectShape
impl<'de> Deserialize<'de> for RectShape
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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> 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