summaryrefslogtreecommitdiffstats
path: root/core/src/rotation.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-05-03 07:04:57 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-05-03 07:04:57 +0200
commiteac5bcb64f17dfbb52b64ea4f95693462986bb69 (patch)
treea4941797a889c47c05f563b7251f315f968357f5 /core/src/rotation.rs
parent568ac66486937a294f2a79cefea277e4eb46b81e (diff)
downloadiced-eac5bcb64f17dfbb52b64ea4f95693462986bb69.tar.gz
iced-eac5bcb64f17dfbb52b64ea4f95693462986bb69.tar.bz2
iced-eac5bcb64f17dfbb52b64ea4f95693462986bb69.zip
Fix `Image::bounds` when rotation present in `iced_graphics`
Diffstat (limited to 'core/src/rotation.rs')
-rw-r--r--core/src/rotation.rs14
1 files changed, 3 insertions, 11 deletions
diff --git a/core/src/rotation.rs b/core/src/rotation.rs
index f36ef089..00a8c302 100644
--- a/core/src/rotation.rs
+++ b/core/src/rotation.rs
@@ -36,20 +36,12 @@ impl Rotation {
Degrees(self.radians().0.to_degrees())
}
- /// Rotates the given [`Size`].
+ /// Applies the [`Rotation`] to the given [`Size`], returning
+ /// the minimum [`Size`] containing the rotated one.
pub fn apply(self, size: Size) -> Size {
match self {
Self::Floating(_) => size,
- Self::Solid(rotation) => {
- let radians = f32::from(rotation);
-
- Size {
- width: (size.width * radians.cos()).abs()
- + (size.height * radians.sin()).abs(),
- height: (size.width * radians.sin()).abs()
- + (size.height * radians.cos()).abs(),
- }
- }
+ Self::Solid(rotation) => size.rotate(rotation),
}
}
}