Fix Image::bounds when rotation present in iced_graphics
This commit is contained in:
parent
568ac66486
commit
eac5bcb64f
5 changed files with 37 additions and 17 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use crate::Vector;
|
||||
use crate::{Radians, Vector};
|
||||
|
||||
/// An amount of space in 2 dimensions.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
|
||||
|
|
@ -51,6 +51,19 @@ impl Size {
|
|||
height: self.height + other.height,
|
||||
}
|
||||
}
|
||||
|
||||
/// Rotates the given [`Size`] and returns the minimum [`Size`]
|
||||
/// containing it.
|
||||
pub fn rotate(self, rotation: Radians) -> Size {
|
||||
let radians = f32::from(rotation);
|
||||
|
||||
Size {
|
||||
width: (self.width * radians.cos()).abs()
|
||||
+ (self.height * radians.sin()).abs(),
|
||||
height: (self.width * radians.sin()).abs()
|
||||
+ (self.height * radians.cos()).abs(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> From<[T; 2]> for Size<T> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue