Skip to main content

Shape

Enum Shape 

Source
pub enum Shape {
    Point(PointShape),
    Line(Segment),
    Polyline(Polyline),
    Rect(Rect),
    Circle(Circle),
    Arc(Arc),
    Path(Path),
    Polygon(Polygon),
    Text(Text),
}
Expand description

A canonical 2D shape.

Variants§

§

Point(PointShape)

Point marker.

§

Line(Segment)

Line segment.

§

Polyline(Polyline)

Polyline (optionally closed, optional arc segments).

§

Rect(Rect)

Axis-aligned rectangle.

§

Circle(Circle)

Circle.

§

Arc(Arc)

Circular arc.

§

Path(Path)

Bézier path.

§

Polygon(Polygon)

Polygon with holes.

§

Text(Text)

Text annotation.

Implementations§

Source§

impl Shape

Source

pub const fn kind(&self) -> ShapeKind

Kind of the shape.

Source

pub fn validate(&self) -> GeoResult<()>

Validate numeric sanity and structural rules.

Source

pub fn curves(&self) -> Vec<Curve>

Decompose into curve pieces. Points and text have none.

Source

pub fn bbox(&self) -> Aabb

Bounding box (text: its layout box with the default font).

Source

pub fn is_region(&self) -> bool

Whether the shape bounds an area (fill and inside tests apply).

Source

pub fn distance_to(&self, p: Point) -> f64

Distance from p to the outline (text: to its layout box).

Source

pub fn contains_point(&self, p: Point, tol: FlattenTolerance) -> bool

Even-odd inside test for regions (always false for non-regions). Straight edges use exact orientation predicates; curved edges are flattened with tol.

Source

pub fn hit(&self, p: Point, radius: f64, fill: bool) -> bool

Hit test: within radius of the outline, or inside when fill is set.

Source

pub fn inside_rect(&self, r: Aabb) -> bool

Window selection: shape entirely inside r.

Source

pub fn intersects_rect(&self, r: Aabb, tol: ModelTolerance) -> bool

Crossing selection: any part of the shape touches r (regions: also when r lies inside the region).

Source

pub fn flatten(&self, tol: FlattenTolerance) -> Vec<FlatPath>

Flatten into polylines/rings with maximum deviation tol.

Source

pub fn anchors(&self) -> Vec<Anchor>

Semantic anchors.

Source

pub fn anchor(&self, name: &str) -> Option<Point>

Anchor by name.

Source

pub fn length(&self) -> f64

Total outline length (text and points: 0).

Source

pub fn area(&self) -> f64

Unsigned area of regions (0 for non-regions). Bézier areas use flattening.

Source

pub fn transform(&self, t: Affine, policy: TransformPolicy) -> GeoResult<Self>

Transform the shape. See TransformPolicy.

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

impl Debug for Shape

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Shape

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Shape

Source§

fn eq(&self, other: &Shape) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Shape

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Shape

Auto Trait Implementations§

§

impl Freeze 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<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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.