Remove nalgebra dependency

- Implement our own `Point` and `Vector` types
  - Make `Rectangle` not generic
This commit is contained in:
Héctor Ramón Jiménez 2019-08-31 04:31:13 +02:00
parent 343cafa1ee
commit eecac7b5d1
18 changed files with 69 additions and 31 deletions

View file

@ -1,25 +1,25 @@
use crate::Point;
/// A generic rectangle.
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub struct Rectangle<T> {
/// A rectangle.
#[derive(Debug, PartialEq, Copy, Clone)]
pub struct Rectangle {
/// X coordinate of the top-left corner.
pub x: T,
pub x: f32,
/// Y coordinate of the top-left corner.
pub y: T,
pub y: f32,
/// Width of the rectangle.
pub width: T,
pub width: f32,
/// Height of the rectangle.
pub height: T,
pub height: f32,
}
impl Rectangle<f32> {
impl Rectangle {
/// Returns true if the given [`Point`] is contained in the [`Rectangle`].
///
/// [`Point`]: type.Point.html
/// [`Point`]: struct.Point.html
/// [`Rectangle`]: struct.Rectangle.html
pub fn contains(&self, point: Point) -> bool {
self.x <= point.x