Skip to main content

Shape

Struct Shape 

Source
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

Source

pub fn rounded( bounds: Bounds<Pixels>, corners: CornerShape, direction: Direction, ) -> Option<Shape>

Resolves Material corner radii against the actual bounds and direction.

Source

pub fn material(bounds: Bounds<Pixels>, shape: MaterialShape) -> Option<Shape>

Prepares one of the 35 Material 3 Expressive shapes fitted inside bounds.

Source

pub fn polygon( bounds: Bounds<Pixels>, polygon: &ShapePolygon, fit: ShapeFit, ) -> Option<Shape>

Prepares any reusable ShapePolygon inside bounds.

Source

pub fn bounds(&self) -> Bounds<Pixels>

Returns the laid-out bounds that this shape was fitted into.

Source

pub fn fill_path(&self) -> &Path<Pixels>

Returns the tessellated fill mesh shared by painting, clipping, and hit testing.

Source

pub fn stroke_path(&self, width: Pixels) -> Option<Path<Pixels>>

Builds a stroked outline path for this shape at the requested logical pixel width.

Source

pub fn contains(&self, position: Point<Pixels>) -> bool

Returns whether position lies inside this shape’s tessellated fill mesh.

Source

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.

Source

pub fn intersects_bounds(&self, rect: Bounds<Pixels>) -> bool

Returns whether this shape’s fill mesh intersects the axis-aligned rectangle rect.

Source

pub fn clip_rect(&self, rect: Bounds<Pixels>) -> Path<Pixels>

Clips an axis-aligned rectangle against this shape’s fill mesh.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn paint(&self, color: Hsla, window: &mut Window)

Paints the tessellated fill mesh with color.

Source

pub fn paint_stroke(&self, width: Pixels, color: Hsla, window: &mut Window)

Paints a stroked outline around this shape.

Source

pub fn paint_clipped( &self, path: &Path<Pixels>, color: Hsla, window: &mut Window, )

Paints path clipped to this shape’s fill mesh.

Source

pub fn paint_clipped_rect( &self, rect: Bounds<Pixels>, color: Hsla, window: &mut Window, )

Paints rect clipped to this shape’s fill mesh.

Source

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.

Source

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.

Source

pub fn paint_shadow( &self, elevation: f32, scale: f32, shadow: Hsla, window: &mut Window, )

Approximates a shape-matched elevation shadow with three translucent fills.

Trait Implementations§

Source§

impl Clone for Shape

Source§

fn clone(&self) -> Shape

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

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> 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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more