From ff9f2234f3e310d2a301478ae27c7af108cfc4c7 Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Wed, 5 Apr 2023 23:19:46 +0100 Subject: [PATCH] `UiImage` helper functions (#8199) # Objective Add helper functions to `UiImage` for creating flipped images. ## Changelog * Added `with_flip_x` and `with_flip_y` methods to `UiImage` that return the `UiImage` flipped along the respective axis. --- crates/bevy_ui/src/ui_node.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index 230b29f0ed..d51e2c8a75 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -758,6 +758,20 @@ impl UiImage { ..Default::default() } } + + /// flip the image along its x-axis + #[must_use] + pub const fn with_flip_x(mut self) -> Self { + self.flip_x = true; + self + } + + /// flip the image along its y-axis + #[must_use] + pub const fn with_flip_y(mut self) -> Self { + self.flip_y = true; + self + } } impl From> for UiImage {