add Outline::with_capacity, Contour::transformed and a small fix
This commit is contained in:
parent
7e05972549
commit
26e41b82ff
|
@ -62,6 +62,14 @@ impl Outline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn with_capacity(capacity: usize) -> Outline {
|
||||||
|
Outline {
|
||||||
|
contours: Vec::with_capacity(capacity),
|
||||||
|
bounds: RectF::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_segments<I>(segments: I) -> Outline
|
pub fn from_segments<I>(segments: I) -> Outline
|
||||||
where
|
where
|
||||||
|
@ -275,7 +283,7 @@ impl Contour {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_rect(rect: RectF) -> Contour {
|
pub fn from_rect(rect: RectF) -> Contour {
|
||||||
let mut contour = Contour::new();
|
let mut contour = Contour::with_capacity(4);
|
||||||
contour.push_point(rect.origin(), PointFlags::empty(), false);
|
contour.push_point(rect.origin(), PointFlags::empty(), false);
|
||||||
contour.push_point(rect.upper_right(), PointFlags::empty(), false);
|
contour.push_point(rect.upper_right(), PointFlags::empty(), false);
|
||||||
contour.push_point(rect.lower_right(), PointFlags::empty(), false);
|
contour.push_point(rect.lower_right(), PointFlags::empty(), false);
|
||||||
|
@ -614,6 +622,12 @@ impl Contour {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn transformed(mut self, transform: &Transform2F) -> Contour {
|
||||||
|
self.transform(transform);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn apply_perspective(&mut self, perspective: &Perspective) {
|
pub fn apply_perspective(&mut self, perspective: &Perspective) {
|
||||||
for (point_index, point) in self.points.iter_mut().enumerate() {
|
for (point_index, point) in self.points.iter_mut().enumerate() {
|
||||||
*point = *perspective * *point;
|
*point = *perspective * *point;
|
||||||
|
|
Loading…
Reference in New Issue