Struct iron_shapes::point_string::PointString [−][src]
A point string is a finite sequence of points.
TODO: Implement Deref
for accessing the list of points.
Fields
points: Vec<Point<T>>
The points defining this point string.
Implementations
impl<T: CoordinateType> PointString<T>
[src]
pub fn new<I>(i: I) -> Self where
I: Into<Self>,
[src]
I: Into<Self>,
Create new point string by taking vertices from a type that implements Into<PointString<T>>
.
pub fn len(&self) -> usize
[src]
Get the number of vertices.
pub fn iter(&self) -> Iter<'_, Point<T>>
[src]
Shortcut for self.points.iter()
.
pub fn edges(&self) -> impl Iterator<Item = Edge<T>> + '_
[src]
Get the sequence of edges of the point string starting from the first point to the last.
Examples
use iron_shapes::point_string::PointString; use iron_shapes::edge::Edge; let coords = vec![(0, 0), (1, 0), (2, 0)]; let point_string = PointString::new(coords); let edges: Vec<_> = point_string.edges().collect(); assert_eq!(edges, vec![Edge::new((0, 0), (1, 0)), Edge::new((1, 0), (2, 0))]);
pub fn edges_reversed(&self) -> impl Iterator<Item = Edge<T>> + '_
[src]
Same as edges
but in reverse order.
Get the sequence of edges of the point string starting from the last point to the first.
Examples
use iron_shapes::point_string::PointString; use iron_shapes::edge::Edge; let coords = vec![(0, 0), (1, 0), (2, 0)]; let point_string = PointString::new(coords); let edges: Vec<_> = point_string.edges_reversed().collect(); assert_eq!(edges, vec![Edge::new((2, 0), (1, 0)), Edge::new((1, 0), (0, 0))]);
impl<T: CoordinateType + NumCast> PointString<T>
[src]
pub fn path_length<F: Float>(&self) -> F
[src]
Compute geometrical length of the path defined by the point string.
Examples
use iron_shapes::point_string::PointString; let coords = vec![(0, 0), (1, 0), (2, 0)]; let point_string = PointString::new(coords); assert_eq!(point_string.path_length::<f64>(), 2.0);
Trait Implementations
impl<T: Clone + CoordinateType> Clone for PointString<T>
[src]
fn clone(&self) -> PointString<T>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Debug + CoordinateType> Debug for PointString<T>
[src]
impl<T: Eq + CoordinateType> Eq for PointString<T>
[src]
impl<I, T, P> From<I> for PointString<T> where
T: CoordinateType,
I: IntoIterator<Item = P>,
Point<T>: From<P>,
[src]
T: CoordinateType,
I: IntoIterator<Item = P>,
Point<T>: From<P>,
Create a point string from something that can be turned into an iterator of values convertible to Point
s.
impl<T, P> FromIterator<P> for PointString<T> where
T: CoordinateType,
P: Into<Point<T>>,
[src]
T: CoordinateType,
P: Into<Point<T>>,
Create a point string from a iterator of values convertible to Point
s.
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = P>,
[src]
I: IntoIterator<Item = P>,
impl<T: Hash + CoordinateType> Hash for PointString<T>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> MapPointwise<T> for PointString<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T: PartialEq + CoordinateType> PartialEq<PointString<T>> for PointString<T>
[src]
fn eq(&self, other: &PointString<T>) -> bool
[src]
fn ne(&self, other: &PointString<T>) -> bool
[src]
impl<T: CoordinateType> StructuralEq for PointString<T>
[src]
impl<T: CoordinateType> StructuralPartialEq for PointString<T>
[src]
impl<T> TryBoundingBox<T> for PointString<T> where
T: CoordinateType,
[src]
T: CoordinateType,
fn try_bounding_box(&self) -> Option<Rect<T>>
[src]
Compute the bounding box of all the points in this string.
Returns None
if the string is empty.
Examples
use iron_shapes::point_string::PointString; use iron_shapes::traits::TryBoundingBox; use iron_shapes::rect::Rect; let coords = vec![(0, 0), (1, 0), (2, 1), (-1, -3)]; let point_string = PointString::new(coords); assert_eq!(point_string.try_bounding_box(), Some(Rect::new((2, 1), (-1, -3))));
impl<T: CoordinateType + NumCast, Dst: CoordinateType + NumCast> TryCastCoord<T, Dst> for PointString<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for PointString<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for PointString<T> where
T: Send,
T: Send,
impl<T> Sync for PointString<T> where
T: Sync,
T: Sync,
impl<T> Unpin for PointString<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for PointString<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<S, T> Mirror<T> for S where
T: CoordinateType,
S: MapPointwise<T>,
[src]
T: CoordinateType,
S: MapPointwise<T>,
pub fn mirror_x(&Self) -> S
[src]
Return the geometrical object mirrored at the x
axis.
pub fn mirror_y(&Self) -> S
[src]
Return the geometrical object mirrored at the y
axis.
impl<S, T> RotateOrtho<T> for S where
T: CoordinateType,
S: MapPointwise<T>,
[src]
T: CoordinateType,
S: MapPointwise<T>,
pub fn rotate_ortho(&Self, Angle) -> S
[src]
impl<S, T> Scale<T> for S where
T: CoordinateType,
S: MapPointwise<T>,
[src]
T: CoordinateType,
S: MapPointwise<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<S, T> Translate<T> for S where
T: CoordinateType,
S: MapPointwise<T>,
[src]
T: CoordinateType,
S: MapPointwise<T>,
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>,