Skip to content

Commit

Permalink
renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
revmischa committed Oct 19, 2024
1 parent ea1e706 commit 1dcab29
Show file tree
Hide file tree
Showing 2 changed files with 194 additions and 152 deletions.
13 changes: 12 additions & 1 deletion src/sdl3/rect.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Rectangles and points.
use crate::sys;
use render::FRect;
use std::convert::{AsMut, AsRef};
use std::hash::{Hash, Hasher};
use std::mem;
Expand Down Expand Up @@ -514,7 +515,6 @@ impl Rect {

let success = unsafe {
sys::rect::SDL_GetRectIntersection(self.raw(), other.raw(), out.as_mut_ptr())

};

if success {
Expand Down Expand Up @@ -626,6 +626,17 @@ impl From<sys::rect::SDL_Rect> for Rect {
}
}

impl Into<Option<FRect>> for Rect {
fn into(self) -> Option<FRect> {
Some(FRect::new(
self.raw.x as f32,
self.raw.y as f32,
self.raw.w as f32,
self.raw.h as f32,
))
}
}

impl From<(i32, i32, u32, u32)> for Rect {
fn from((x, y, width, height): (i32, i32, u32, u32)) -> Rect {
Rect::new(x, y, width, height)
Expand Down
Loading

0 comments on commit 1dcab29

Please sign in to comment.