#![allow(clippy::inline_always)]
use super::Buffer;
use crate::{
prelude::{IntoPatch, TryIntoPatch},
render::BufferCollision,
};
impl Buffer {
#[deprecated = "Use `to_collision` instead"]
#[must_use]
pub const fn create_collision_usize<const CS: bool>(
&self,
pos: (usize, usize),
) -> crate::math::geometry::Pos2D<
usize,
crate::math::collision::Rectangle<usize, CS>,
>
where
usize: [const] IntoPatch<usize>,
{
self.to_collision(pos)
}
#[deprecated = "Use `try_to_collision` instead"]
#[must_use]
#[allow(clippy::cast_possible_wrap)]
pub const fn create_collision<
const CS: bool,
T: core::ops::Add<Output = T>
+ PartialOrd
+ Copy
+ core::ops::Div<Output = T>,
>(
&self,
pos: (T, T),
) -> Option<
crate::math::geometry::Pos2D<
T,
crate::math::collision::Rectangle<T, CS>,
>,
>
where
usize: [const] TryIntoPatch<T>,
{
self.try_to_collision(pos)
}
#[must_use]
#[inline(always)]
pub const fn is_pixel_position_in_buffer(
&self,
x: usize,
y: usize,
) -> bool {
x < self.width && y < self.height
}
#[must_use]
#[inline(always)]
#[allow(clippy::cast_sign_loss)]
pub const fn is_pixel_position_in_buffer_isize(
&self,
x: isize,
y: isize,
) -> bool {
x > 0
&& y > 0
&& (x as usize) < self.width
&& (y as usize) < self.height
}
}