pub fn move_coords(self, coords: Vec2, bounds: Bounds) -> Option<Vec2> {
        match self {
            // (-Y)
            Direction::Up => {
                if coords.y > bounds.min.y {
                    Some(Vec2 { y: coords.y - 1, ..coords })
                } else {
                    None
                }
            },

            // (+Y)
            Direction::Down => {
                if coords.y < bounds.max.y {
                    Some(Vec2 { y: coords.y + 1, ..coords })
                } else {
                    None
                }
            },

            // (-X)
            Direction::Left => {
                if coords.x > bounds.min.x {
                    Some(Vec2 { x: coords.x - 1, ..coords })
                } else {
                    None
                }
            },

            // (+X)
            Direction::Right => {
                if coords.x < bounds.max.x {
                    Some(Vec2 { x: coords.x + 1, ..coords })
                } else {
                    None
                }
            },
        }
    }
/// Moves a point through this direction. Returns `None` if out of bounds.
Moves a point through this direction. Returns `None` if out of bounds.
Moves a point through this direction . Returns ` None ` if out of bounds .
pub fn move_coords(self, coords: Vec2, bounds: Bounds) -> Option<Vec2> {
        match self {
            // (-Y)
            Direction::Up => {
                if coords.y > bounds.min.y {
                    Some(Vec2 { y: coords.y - 1, ..coords })
                } else {
                    None
                }
            },
            // (+Y)
            Direction::Down => {
                if coords.y < bounds.max.y {
                    Some(Vec2 { y: coords.y + 1, ..coords })
                } else {
                    None
                }
            },
            // (-X)
            Direction::Left => {
                if coords.x > bounds.min.x {
                    Some(Vec2 { x: coords.x - 1, ..coords })
                } else {
                    None
                }
            },
            // (+X)
            Direction::Right => {
                if coords.x < bounds.max.x {
                    Some(Vec2 { x: coords.x + 1, ..coords })
                } else {
                    None
                }
            },
        }
    }
pub fn move_coords ( self , coords : Vec2 , bounds : Bounds ) -> Option < Vec2 > { match self { // (-Y) Direction :: Up => { if coords . y > bounds . min . y { Some ( Vec2 { y : coords . y - 1 , .. coords } ) } else { None } } , // (+Y) Direction :: Down => { if coords . y < bounds . max . y { Some ( Vec2 { y : coords . y + 1 , .. coords } ) } else { None } } , // (-X) Direction :: Left => { if coords . x > bounds . min . x { Some ( Vec2 { x : coords . x - 1 , .. coords } ) } else { None } } , // (+X) Direction :: Right => { if coords . x < bounds . max . x { Some ( Vec2 { x : coords . x + 1 , .. coords } ) } else { None } } , } }
Moves a point through this direction.
Moves a point through this direction .
self
coords
Vec2
bounds
Bounds
self
coords
Vec2
bounds
Bounds