pub struct Shape { /* private fields */ }Expand description
A prepared shape with a curve path for painting and lazily built caches for clipping, stroking, shadows, exterior masking, and hit testing.
Implementations§
Source§impl Shape
impl Shape
Sourcepub fn rounded(
bounds: Bounds<Pixels>,
corners: CornerShape,
direction: Direction,
) -> Option<Shape>
pub fn rounded( bounds: Bounds<Pixels>, corners: CornerShape, direction: Direction, ) -> Option<Shape>
Resolves Material corner radii against the actual bounds and direction.
Sourcepub fn material(bounds: Bounds<Pixels>, shape: MaterialShape) -> Option<Shape>
pub fn material(bounds: Bounds<Pixels>, shape: MaterialShape) -> Option<Shape>
Prepares one of the 35 Material 3 Expressive shapes fitted inside bounds.
Sourcepub fn polygon(
bounds: Bounds<Pixels>,
polygon: &ShapePolygon,
fit: ShapeFit,
) -> Option<Shape>
pub fn polygon( bounds: Bounds<Pixels>, polygon: &ShapePolygon, fit: ShapeFit, ) -> Option<Shape>
Prepares any reusable ShapePolygon inside bounds.
Sourcepub fn bounds(&self) -> Bounds<Pixels>
pub fn bounds(&self) -> Bounds<Pixels>
Returns the laid-out bounds that this shape was fitted into.
Sourcepub fn fill_bounds(&self) -> Bounds<Pixels>
pub fn fill_bounds(&self) -> Bounds<Pixels>
Returns the tight bounding box of this shape’s flattened fill contour.
Sourcepub fn stroke_path(&self, width: Pixels) -> Option<Path>
pub fn stroke_path(&self, width: Pixels) -> Option<Path>
Builds a stroked outline path for this shape at the requested logical pixel width.
Sourcepub fn stroke_path_outset(&self, width: Pixels, outset: Pixels) -> Option<Path>
pub fn stroke_path_outset(&self, width: Pixels, outset: Pixels) -> Option<Path>
Builds a stroked outline path expanded outward by outset (or inset when negative).
Cached per (width, outset) pair so borders and focus rings hit simultaneously.
Sourcepub fn contains(&self, position: Point<Pixels>) -> bool
pub fn contains(&self, position: Point<Pixels>) -> bool
Returns whether position lies inside this shape’s fill mesh.
Sourcepub fn hit_test(&self, position: Point<Pixels>, slop: Pixels) -> bool
pub fn hit_test(&self, position: Point<Pixels>, slop: Pixels) -> bool
Shape-aware hit test against the fill mesh with an optional outward slop
tolerance in logical pixels. Non-finite coordinates return false.
Sourcepub fn intersects_bounds(&self, rect: Bounds<Pixels>) -> bool
pub fn intersects_bounds(&self, rect: Bounds<Pixels>) -> bool
Returns whether this shape’s fill mesh intersects the axis-aligned rectangle rect.
Sourcepub fn clip_rect(&self, rect: Bounds<Pixels>) -> Option<Path>
pub fn clip_rect(&self, rect: Bounds<Pixels>) -> Option<Path>
Clips an axis-aligned rectangle against this shape’s fill mesh.
Sourcepub fn clip_disc(&self, origin: Point<Pixels>, radius: Pixels) -> Option<Path>
pub fn clip_disc(&self, origin: Point<Pixels>, radius: Pixels) -> Option<Path>
Clips a disc centered at origin with logical radius against this shape’s fill mesh.
Sourcepub fn clip_convex_polygon(&self, vertices: &[Point<Pixels>]) -> Option<Path>
pub fn clip_convex_polygon(&self, vertices: &[Point<Pixels>]) -> Option<Path>
Clips a convex polygon (in either winding order) against this shape’s fill mesh.
Sourcepub fn clip_shape(&self, source: &Shape) -> Option<Path>
pub fn clip_shape(&self, source: &Shape) -> Option<Path>
Clips another Shape (convex or concave) against this shape’s fill mesh,
returning the exact geometric intersection.
Sourcepub fn exterior_mask(&self, outer: Bounds<Pixels>) -> Option<Path>
pub fn exterior_mask(&self, outer: Bounds<Pixels>) -> Option<Path>
Builds an EvenOdd exterior mask representing outer \ self within outer.
Because GPUI’s native ContentMask is rectangular, painting this exterior mask
in a uniform parent backdrop color visually clips arbitrary child elements to the
exact non-rectangular shape contour.
Sourcepub fn paint_stroke(&self, width: Pixels, color: Hsla, window: &mut Window)
pub fn paint_stroke(&self, width: Pixels, color: Hsla, window: &mut Window)
Paints a stroked outline around this shape.
Sourcepub fn paint_clipped_shape(
&self,
source: &Shape,
color: Hsla,
window: &mut Window,
)
pub fn paint_clipped_shape( &self, source: &Shape, color: Hsla, window: &mut Window, )
Paints source clipped to this shape’s fill mesh.
Sourcepub fn paint_clipped_rect(
&self,
rect: Bounds<Pixels>,
color: Hsla,
window: &mut Window,
)
pub fn paint_clipped_rect( &self, rect: Bounds<Pixels>, color: Hsla, window: &mut Window, )
Paints rect clipped to this shape’s fill mesh.
Sourcepub fn paint_clipped_disc(
&self,
origin: Point<Pixels>,
radius: Pixels,
color: Hsla,
window: &mut Window,
)
pub fn paint_clipped_disc( &self, origin: Point<Pixels>, radius: Pixels, color: Hsla, window: &mut Window, )
Paints a disc clipped to this shape’s fill mesh.
Sourcepub fn paint_backdrop_mask(
&self,
outer: Bounds<Pixels>,
backdrop: Hsla,
window: &mut Window,
)
pub fn paint_backdrop_mask( &self, outer: Bounds<Pixels>, backdrop: Hsla, window: &mut Window, )
Paints the EvenOdd exterior mask outer \ self in backdrop to visually clip
overflowing children to this shape on a uniform background.
Sourcepub fn paint_shadow(
&self,
elevation: f32,
scale: f32,
shadow: Hsla,
window: &mut Window,
)
pub fn paint_shadow( &self, elevation: f32, scale: f32, shadow: Hsla, window: &mut Window, )
Approximates a shape-matched elevation shadow with three translucent fills.
Sourcepub fn focus_ring_path(
&self,
width: Pixels,
placement: FocusRingPlacement,
) -> Option<Path>
pub fn focus_ring_path( &self, width: Pixels, placement: FocusRingPlacement, ) -> Option<Path>
Computes the Material 3 focus ring stroke path for the given width and placement.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Shape
impl !Send for Shape
impl !Sync for Shape
impl !UnwindSafe for Shape
impl Forget for Shape
impl Freeze for Shape
impl Move for Shape
impl Unpin for Shape
impl UnsafeUnpin for Shape
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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