Skip to main content

Shape

Enum Shape 

Source
pub enum Shape {
    Rect {
        min: Point,
        max: Point,
    },
    Capsule {
        a: Point,
        b: Point,
        radius: i32,
    },
    RoundRect {
        min: Point,
        max: Point,
        radius: i32,
    },
    Polygon {
        points: Vec<Point>,
        radius: i32,
    },
}
Expand description

A copper primitive for clearance and connectivity calculations.

Variants§

§

Rect

Fields

§min: Point
§max: Point
§

Capsule

A segment swept by a disc. A circle has a == b.

Fields

§radius: i32
§

RoundRect

A rectangle with corners rounded by radius: the rectangle min..max shrunk by radius on every side, swept by a disc of radius.

Fields

§min: Point
§max: Point
§radius: i32
§

Polygon

A simple polygon swept by a disc of radius: a trapezoid or custom pad’s copper (rounded by its corner radius), and its mask opening grown from it. points run counter-clockwise in a y-up frame, as Shape::polygon puts them.

Fields

§points: Vec<Point>
§radius: i32

Implementations§

Source§

impl Shape

Source

pub fn polygon(points: Vec<Point>, radius: i32) -> Self

A polygon swept by a disc of radius, its corners turned to run counter-clockwise in a y-up frame (a positive signed area in board coordinates) whichever way they were given, so a mirrored part’s pad has the same winding as any other.

Source

pub fn covers_box(&self, min: Point, max: Point) -> bool

Whether the shape covers the whole box min..max.

Source

pub fn pad(center: Point, size: Point, shape: PadShape) -> Self

A pad’s copper, a rounded rectangle taken square-cornered (Shape::rounded_pad gives it its corners).

Source

pub fn rounded_pad( center: Point, size: Point, shape: PadShape, corner: i32, ) -> Self

A pad’s copper. corner is the corner radius of a rounded rectangle (0 makes it an ordinary rectangle); other shapes ignore it.

Source

pub fn circle(center: Point, radius: i32) -> Self

Source

pub fn segment(a: Point, b: Point, width: i32) -> Self

Source

pub fn grown(&self, grow: i32) -> Self

The shape grown by grow on every side (shrunk when negative): a pad’s solder mask opening or paste aperture. A shrink never inverts the shape.

Source

pub fn swept_corners(&self) -> Option<Vec<SweptCorner>>

A rounded polygon’s outline as exact arcs and the straights between them, for a host that draws curves (the STEP export). None for any other shape, an unrounded polygon (its corners are its outline), or one whose rounding fills a notch, where only Shape::outline is exact.

Source

pub fn grown_parts(&self, grow: i32) -> Vec<Self>

The shape grown by grow, as Shape::grown, but a polygon that a shrink cuts in two keeps every piece (two lands joined by a thin bridge each keep their paste); a shrink that leaves nothing gives none.

Source

pub fn outline(&self, facets: usize) -> Vec<Point>

The outline as a closed polygon, counter-clockwise in a y-up frame, arcs faceted facets to the quarter turn, each vertex ON the true outline.

Source

pub fn bounds(&self) -> (Point, Point)

Source

pub fn center(&self) -> Point

Source

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

Distance from a point to the shape; zero inside.

Source

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

How deep p lies inside the shape: its distance to the boundary, positive inside and negative outside.

Source

pub fn contains(&self, p: Point) -> bool

Source

pub fn distance(&self, other: &Self) -> f64

Gap between two shapes; zero when they touch or overlap.

Trait Implementations§

Source§

impl Clone for Shape

Source§

fn clone(&self) -> Self

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 PartialEq for Shape

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Shape

Auto Trait Implementations§

§

impl Forget for Shape

§

impl Freeze 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<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> 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 = !

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.