Skip to content

Commit

Permalink
Rework constructors for Negate
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatur committed Oct 10, 2024
1 parent 3efbae5 commit 8bff54f
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/input_context/input_modifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ pub enum SmoothingMethod {

/// Inverts value per axis.
///
/// Inverses all axes by default.
/// By default, all axes are inverted.
#[derive(Debug)]
pub struct Negate {
pub x: bool,
Expand All @@ -366,30 +366,39 @@ pub struct Negate {
}

impl Negate {
/// Returns [`Self`] with only x negated.
pub fn x() -> Self {
/// Returns [`Self`] with invertion for all axes set to `invert`
pub fn all(invert: bool) -> Self {
Self {
x: true,
x: invert,
y: invert,
z: invert,
}
}

/// Returns [`Self`] with invertion for x set to `invert`
pub fn x(invert: bool) -> Self {
Self {
x: invert,
y: false,
z: false,
}
}

/// Returns [`Self`] with only y negated.
pub fn y() -> Self {
/// Returns [`Self`] with invertion for y set to `invert`
pub fn y(invert: bool) -> Self {
Self {
x: false,
y: true,
y: invert,
z: false,
}
}

/// Returns [`Self`] with only z negated.
pub fn z() -> Self {
/// Returns [`Self`] with invertion for z set to `invert`
pub fn z(invert: bool) -> Self {
Self {
x: false,
y: false,
z: true,
z: invert,
}
}
}
Expand Down

0 comments on commit 8bff54f

Please sign in to comment.