pub struct Shape { /* private fields */ }Expand description
A prepared shape with a shared mesh for drawing, clipping, hit testing, and effects.
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_path(&self) -> &Path<Pixels>
pub fn fill_path(&self) -> &Path<Pixels>
Returns the tessellated fill mesh shared by painting, clipping, and hit testing.
Sourcepub fn stroke_path(&self, width: Pixels) -> Option<Path<Pixels>>
pub fn stroke_path(&self, width: Pixels) -> Option<Path<Pixels>>
Builds a stroked outline path for this shape at the requested logical pixel width.
Sourcepub fn contains(&self, position: Point<Pixels>) -> bool
pub fn contains(&self, position: Point<Pixels>) -> bool
Returns whether position lies inside this shape’s tessellated 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 tessellated 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>) -> Path<Pixels>
pub fn clip_rect(&self, rect: Bounds<Pixels>) -> Path<Pixels>
Clips an axis-aligned rectangle against this shape’s fill mesh.
Sourcepub fn clip_disc(&self, origin: Point<Pixels>, radius: Pixels) -> Path<Pixels>
pub fn clip_disc(&self, origin: Point<Pixels>, radius: Pixels) -> Path<Pixels>
Clips a disc centered at origin with logical radius against this shape’s fill mesh.
Sourcepub fn clip_convex_polygon(&self, vertices: &[Point<Pixels>]) -> Path<Pixels>
pub fn clip_convex_polygon(&self, vertices: &[Point<Pixels>]) -> Path<Pixels>
Clips a convex polygon (in either winding order) against this shape’s fill mesh.
Sourcepub fn clip_path(&self, source: &Path<Pixels>) -> Path<Pixels>
pub fn clip_path(&self, source: &Path<Pixels>) -> Path<Pixels>
Clips an arbitrary tessellated GPUI Path (convex or concave) against this shape’s
fill mesh, returning the exact geometric intersection.
Sourcepub fn exterior_mask(&self, outer: Bounds<Pixels>) -> Option<Path<Pixels>>
pub fn exterior_mask(&self, outer: Bounds<Pixels>) -> Option<Path<Pixels>>
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(&self, color: Hsla, window: &mut Window)
pub fn paint(&self, color: Hsla, window: &mut Window)
Paints the tessellated fill mesh with color.
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(
&self,
path: &Path<Pixels>,
color: Hsla,
window: &mut Window,
)
pub fn paint_clipped( &self, path: &Path<Pixels>, color: Hsla, window: &mut Window, )
Paints path 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.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Shape
impl Forget for Shape
impl Move for Shape
impl RefUnwindSafe for Shape
impl Send for Shape
impl Sync for Shape
impl Unpin for Shape
impl UnsafeUnpin for Shape
impl UnwindSafe 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