Skip to content

Commit

Permalink
UiImage helper functions (#8199)
Browse files Browse the repository at this point in the history
# 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.
  • Loading branch information
ickshonpe authored Apr 5, 2023
1 parent 28046d5 commit ff9f223
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions crates/bevy_ui/src/ui_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Handle<Image>> for UiImage {
Expand Down

0 comments on commit ff9f223

Please sign in to comment.