pub struct Position { /* private fields */ }
Expand description
Represents the size, location and centerpoint of a shape. We align shapes along their center points, and have edges directed at the center. Shapes like Box and Circle have their center point in the middle, but labels have their center point in one of the sides to make sure that edges don’t obscure the text. The halo is the gap around the shape where nothing can be placed and it is applied symmetrically to the sides.
This struct has fields that represent the following points:
| _____________ | | | | | | | | | | | M <––|—|–the middle of the shape, in absolute coordinates. | | C <-|—|–the center point, saved as delta, relative to M. | |_____________| | | ^—|— the size of the shape. |____________________| <—– size + halo.
Implementations§
Source§impl Position
impl Position
pub fn new(middle: Point, size: Point, center: Point, halo: Point) -> Self
pub fn distance_to_left(&self, with_halo: bool) -> f64
pub fn distance_to_right(&self, with_halo: bool) -> f64
pub fn left(&self, with_halo: bool) -> f64
pub fn right(&self, with_halo: bool) -> f64
pub fn top(&self, with_halo: bool) -> f64
pub fn bottom(&self, with_halo: bool) -> f64
pub fn bbox(&self, with_halo: bool) -> (Point, Point)
pub fn size(&self, with_halo: bool) -> Point
Sourcepub fn in_x_range(&self, range: (f64, f64), with_halo: bool) -> bool
pub fn in_x_range(&self, range: (f64, f64), with_halo: bool) -> bool
\return True if the box fits within the x ranges of \p range.
pub fn set_size(&mut self, size: Point)
Sourcepub fn set_new_center_point(&mut self, center: Point)
pub fn set_new_center_point(&mut self, center: Point)
Update the center point for the shape. This is expressed as the delta from the center of mass (middle-point).
pub fn move_to(&mut self, p: Point)
pub fn align_to_top(&mut self, y: f64)
pub fn align_to_left(&mut self, x: f64)
pub fn align_to_right(&mut self, x: f64)
pub fn translate(&mut self, d: Point)
Sourcepub fn align_x(&mut self, x: f64, to_left: bool)
pub fn align_x(&mut self, x: f64, to_left: bool)
Align the shape to the line \p x, to the right or the left, depending on \p to_left.