Struct libreda_db::layout::prelude::Path[][src]

pub struct Path<T> where
    T: CoordinateType
{ pub points: PointString<T>, pub width: T, pub path_type: PathEndType<T>, }

Path is essentially a chain of line segments but with a possibly a non-zero width. It can be thought of the shape resulting by a stroke of a thick pen along the line segments.

Fields

points: PointString<T>

The vertices of the path which define the sequence of line segments.

width: T

Width of the path.

path_type: PathEndType<T>

Type of the path endings.

Implementations

impl<T> Path<T> where
    T: CoordinateType
[src]

pub fn new<I>(i: I, width: T) -> Path<T> where
    I: Into<PointString<T>>, 
[src]

Create new path by taking vertices from a type that implements Into<PointString<T>>.

pub fn new_extended<I>(i: I, width: T, ext_begin: T, ext_end: T) -> Path<T> where
    I: Into<PointString<T>>, 
[src]

Create a path with extended beginning and end.

pub fn new_rounded<I>(i: I, width: T) -> Path<T> where
    I: Into<PointString<T>>, 
[src]

Create a path with rounded beginning and end.

pub fn translate(&self, v: Vector<T>) -> Path<T>[src]

Translate the path by an offset vector.

pub fn len(&self) -> usize[src]

Get number of vertices defining the path.

pub fn scale(&self, factor: T) -> Path<T>[src]

Scale the path. Scaling center is the origin (0, 0).

pub fn rotate_ortho(&self, angle: Angle) -> Path<T>[src]

Rotate the path by a multiple of 90 degrees around the origin (0, 0).

pub fn transform(&self, tf: &SimpleTransform<T>) -> Path<T>[src]

Get the transformed version of this path by applying tf.

impl<T> Path<T> where
    T: CoordinateType + NumCast
[src]

pub fn area_approx<F>(&self) -> F where
    F: Float
[src]

Compute approximate area occupied by the path. Simply computes length*width.

Examples

use iron_shapes::prelude::*;
let path = Path::new(&[(0, 0), (0, 2)], 1);
assert_eq!(path.area_approx::<f64>(), 2f64);

pub fn to_polygon_approx(&self) -> SimplePolygon<f64>[src]

Convert the path into a polygon. The polygon can be self-intersecting.

Examples

use iron_shapes::prelude::*;
let path = Path::new(&[(0, 0), (10, 0), (10, 20)], 4);
let polygon = path.to_polygon_approx();
assert_eq!(polygon, SimplePolygon::from(&[(0., 2.), (0., -2.), (12., -2.), (12., 20.), (8., 20.), (8., 2.)]));

Trait Implementations

impl<T> Clone for Path<T> where
    T: CoordinateType + Clone
[src]

impl<T> Debug for Path<T> where
    T: CoordinateType + Debug
[src]

impl<T> Eq for Path<T> where
    T: CoordinateType + Eq
[src]

impl<T> From<Path<T>> for Geometry<T> where
    T: CoordinateType
[src]

impl<T> Hash for Path<T> where
    T: CoordinateType + Hash
[src]

impl<T> PartialEq<Path<T>> for Path<T> where
    T: CoordinateType + PartialEq<T>, 
[src]

impl<T> StructuralEq for Path<T> where
    T: CoordinateType
[src]

impl<T> StructuralPartialEq for Path<T> where
    T: CoordinateType
[src]

impl<T> TryBoundingBox<T> for Path<T> where
    T: CoordinateType
[src]

pub fn try_bounding_box(&self) -> Option<Rect<T>>[src]

Compute the bounding box of this path. The returned bounding box is not necessarily the smallest bounding box.

TODO: Find a better approximation.

impl<T, Dst> TryCastCoord<T, Dst> for Path<T> where
    T: CoordinateType + NumCast,
    Dst: CoordinateType + NumCast
[src]

type Output = Path<Dst>

Output type of the cast. This is likely the same geometrical type just with other coordinate types. Read more

Auto Trait Implementations

impl<T> RefUnwindSafe for Path<T> where
    T: RefUnwindSafe

impl<T> Send for Path<T> where
    T: Send

impl<T> Sync for Path<T> where
    T: Sync

impl<T> Unpin for Path<T> where
    T: Unpin

impl<T> UnwindSafe for Path<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> TextType for T where
    T: Clone + Eq + Debug + Hash
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.