Consistently convert coordinates.

This commit is contained in:
Nolan Darilek 2022-05-18 10:28:19 -05:00
parent 34b10aaca4
commit 480e3cc6a5

View File

@ -222,19 +222,19 @@ pub trait PointLike {
fn y(&self) -> f32;
fn x_i32(&self) -> i32 {
self.x() as i32
self.x().trunc() as i32
}
fn y_i32(&self) -> i32 {
self.y() as i32
self.y().trunc() as i32
}
fn x_usize(&self) -> usize {
self.x() as usize
self.x().trunc() as usize
}
fn y_usize(&self) -> usize {
self.y() as usize
self.y().trunc() as usize
}
fn f32(&self) -> (f32, f32) {
@ -248,6 +248,7 @@ pub trait PointLike {
fn floor(&self) -> (f32, f32) {
(self.x().floor(), self.y().floor())
}
fn to_index(&self, width: usize) -> usize {
((self.y_i32() * width as i32) + self.x_i32()) as usize
}