Struct libreda_db::layout::prelude::Path [−][src]
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]
T: CoordinateType,
pub fn new<I>(i: I, width: T) -> Path<T> where
I: Into<PointString<T>>,
[src]
I: Into<PointString<T>>,
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]
I: Into<PointString<T>>,
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]
I: Into<PointString<T>>,
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]
T: CoordinateType + NumCast,
pub fn area_approx<F>(&self) -> F where
F: Float,
[src]
F: Float,
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]
T: CoordinateType + Clone,
impl<T> Debug for Path<T> where
T: CoordinateType + Debug,
[src]
T: CoordinateType + Debug,
impl<T> Eq for Path<T> where
T: CoordinateType + Eq,
[src]
T: CoordinateType + Eq,
impl<T> From<Path<T>> for Geometry<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> Hash for Path<T> where
T: CoordinateType + Hash,
[src]
T: CoordinateType + Hash,
pub fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> PartialEq<Path<T>> for Path<T> where
T: CoordinateType + PartialEq<T>,
[src]
T: CoordinateType + PartialEq<T>,
impl<T> StructuralEq for Path<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> StructuralPartialEq for Path<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> TryBoundingBox<T> for Path<T> where
T: CoordinateType,
[src]
T: CoordinateType,
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]
T: CoordinateType + NumCast,
Dst: CoordinateType + NumCast,
Auto Trait Implementations
impl<T> RefUnwindSafe for Path<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Path<T> where
T: Send,
T: Send,
impl<T> Sync for Path<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Path<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Path<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> TextType for T where
T: Clone + Eq + Debug + Hash,
[src]
T: Clone + Eq + Debug + Hash,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,