Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix into and from component tuple conversion for Yxy #99

Merged
merged 1 commit into from
May 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 8 additions & 32 deletions palette/src/yxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,26 +100,14 @@ where
}
}

/// Convert to a `(y, x, luma)`, a.k.a. `(y, x, Y)` tuple.
/// Convert to a `(x, y, luma)`, a.k.a. `(x, y, Y)` tuple.
pub fn into_components(self) -> (T, T, T) {
(self.y, self.x, self.luma)
}

/// Convert from a `(y, x, luma)`, a.k.a. `(y, x, Y)` tuple.
pub fn from_components((y, x, luma): (T, T, T)) -> Self {
Self::with_wp(y, x, luma)
}

/// Convert to a `(x, y, luma)`, a.k.a. `(x, y, Y)` tuple, which is the
/// more classical component order.
pub fn into_xyy_components(self) -> (T, T, T) {
(self.x, self.y, self.luma)
}

/// Convert from a `(x, y, luma)`, a.k.a. `(x, y, Y)` tuple, which is the
/// more classical component order.
pub fn from_xyy_components((x, y, luma): (T, T, T)) -> Self {
Self::with_wp(y, x, luma)
/// Convert from a `(x, y, luma)`, a.k.a. `(x, y, Y)` tuple.
pub fn from_components((x, y, luma): (T, T, T)) -> Self {
Self::with_wp(x, y, luma)
}
}

Expand Down Expand Up @@ -152,26 +140,14 @@ where
}
}

/// Convert to a `(y, x, luma)`, a.k.a. `(y, x, Y)` tuple.
/// Convert to a `(x, y, luma)`, a.k.a. `(x, y, Y)` tuple.
pub fn into_components(self) -> (T, T, T, A) {
(self.y, self.x, self.luma, self.alpha)
}

/// Convert from a `(y, x, luma)`, a.k.a. `(y, x, Y)` tuple.
pub fn from_components((y, x, luma, alpha): (T, T, T, A)) -> Self {
Self::with_wp(y, x, luma, alpha)
}

/// Convert to a `(x, y, luma)`, a.k.a. `(x, y, Y)` tuple, which is the
/// more classical component order.
pub fn into_xyy_components(self) -> (T, T, T, A) {
(self.x, self.y, self.luma, self.alpha)
}

/// Convert from a `(x, y, luma)`, a.k.a. `(x, y, Y)` tuple, which is the
/// more classical component order.
pub fn from_xyy_components((x, y, luma, alpha): (T, T, T, A)) -> Self {
Self::with_wp(y, x, luma, alpha)
/// Convert from a `(x, y, luma)`, a.k.a. `(x, y, Y)` tuple.
pub fn from_components((x, y, luma, alpha): (T, T, T, A)) -> Self {
Self::with_wp(x, y, luma, alpha)
}
}

Expand Down