pub struct Point { /* private fields */ }Expand description
A 2D point with x and y coordinates, each carrying their own unit of measurement.
Implementations§
Source§impl Point
impl Point
Sourcepub const fn integer(x: i32, y: i32, units: f64) -> Self
pub const fn integer(x: i32, y: i32, units: f64) -> Self
Creates a point with integer coordinates and the given units.
Sourcepub const fn float(x: f64, y: f64, units: f64) -> Self
pub const fn float(x: f64, y: f64, units: f64) -> Self
Creates a point with float coordinates and the given units.
Sourcepub const fn default_integer(x: i32, y: i32) -> Self
pub const fn default_integer(x: i32, y: i32) -> Self
Creates a point with integer coordinates and default integer units (1e-9).
Sourcepub const fn default_float(x: f64, y: f64) -> Self
pub const fn default_float(x: f64, y: f64) -> Self
Creates a point with float coordinates and default float units (1e-6).
Sourcepub const fn new(x: Unit, y: Unit) -> Self
pub const fn new(x: Unit, y: Unit) -> Self
Create a point with two arbitrary units.
This is useful for when you want to create a point with different units. This is not highly recommended.
Sourcepub const fn units(&self) -> (f64, f64)
pub const fn units(&self) -> (f64, f64)
Returns the units for both coordinates as (x_units, y_units).
Sourcepub const fn set_units(&self, units: f64) -> Self
pub const fn set_units(&self, units: f64) -> Self
Returns a copy of this point with both coordinates set to the given units (without scaling).
Sourcepub fn scale_units(&self, new_units: f64) -> Self
pub fn scale_units(&self, new_units: f64) -> Self
Returns a copy of this point with both coordinates scaled to the given units.
Sourcepub fn to_integer_unit(&self) -> Self
pub fn to_integer_unit(&self) -> Self
Converts both coordinates to integer units.
§Returns
A new Point with both x and y coordinates converted to Unit::Integer
Sourcepub fn to_float_unit(&self) -> Self
pub fn to_float_unit(&self) -> Self
Converts both coordinates to float units.
§Returns
A new Point with both x and y coordinates converted to Unit::Float
Sourcepub fn rotate_around_point(&self, angle: AngleInRadians, center: &Self) -> Self
pub fn rotate_around_point(&self, angle: AngleInRadians, center: &Self) -> Self
Trait Implementations§
Source§impl Transformable for Point
impl Transformable for Point
Source§fn transform_impl(self, transformation: &Transformation) -> Self
fn transform_impl(self, transformation: &Transformation) -> Self
Source§fn transform(self, transformation: impl Into<Transformation>) -> Self
fn transform(self, transformation: impl Into<Transformation>) -> Self
Source§fn rotate(self, angle: AngleInRadians, centre: Point) -> Self
fn rotate(self, angle: AngleInRadians, centre: Point) -> Self
Source§fn scale(self, factor: f64, centre: Point) -> Self
fn scale(self, factor: f64, centre: Point) -> Self
impl Copy for Point
impl StructuralPartialEq for Point
Auto Trait Implementations§
impl Freeze for Point
impl RefUnwindSafe for Point
impl Send for Point
impl Sync for Point
impl Unpin for Point
impl UnsafeUnpin for Point
impl UnwindSafe for Point
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more