From 0e9624a5f86f5a02ffa56b04dddfb2dfbab2c85b Mon Sep 17 00:00:00 2001 From: sagudev <16504129+sagudev@users.noreply.github.com> Date: Mon, 6 Oct 2025 10:44:10 +0200 Subject: [PATCH 1/2] Add `lerp_rect_unpremultiplied` Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- color/src/color.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/color/src/color.rs b/color/src/color.rs index be5a07a..915641d 100644 --- a/color/src/color.rs +++ b/color/src/color.rs @@ -475,6 +475,16 @@ impl AlphaColor { .un_premultiply() } + /// Interpolate colors in without premultiplying alpha (so in unpremultiplied "straight" alpha space). + /// + /// Note: this function doesn't fix up hue in cylindrical spaces. It is + /// still useful if the hue angles are compatible, particularly if the + /// fixup has been applied. + #[must_use] + pub fn lerp_rect_unpremultiplied(self, other: Self, t: f32) -> Self { + self + t * (other - self) + } + /// Linearly interpolate colors, with hue fixup if needed. #[must_use] pub fn lerp(self, other: Self, t: f32, direction: HueDirection) -> Self { From a333d64f308e50b9db7ebb3eabaab3914c4aa918 Mon Sep 17 00:00:00 2001 From: sagudev <16504129+sagudev@users.noreply.github.com> Date: Mon, 6 Oct 2025 10:49:56 +0200 Subject: [PATCH 2/2] f Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- CHANGELOG.md | 5 +++++ color/src/color.rs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eff0e72..12fc10e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ You can find its changes [documented below](#032-2025-09-10). This release has an [MSRV][] of 1.82. +### Added + +* Add `lerp_rect_unpremultiplied` to interpolate `AlphaColor` without premultiplying alpha (in unpremultiplied "straight" alpha space). ([#199][] by [@tomcur][]) + ## [0.3.2][] (2025-09-10) This release has an [MSRV][] of 1.82. @@ -209,6 +213,7 @@ This is the initial release. [#175]: https://github.com/linebender/color/pull/175 [#185]: https://github.com/linebender/color/pull/185 [#190]: https://github.com/linebender/color/pull/190 +[#199]: https://github.com/linebender/color/pull/199 [Unreleased]: https://github.com/linebender/color/compare/v0.3.2...HEAD [0.3.2]: https://github.com/linebender/color/releases/tag/v0.3.2 diff --git a/color/src/color.rs b/color/src/color.rs index 915641d..2d0bfba 100644 --- a/color/src/color.rs +++ b/color/src/color.rs @@ -475,7 +475,7 @@ impl AlphaColor { .un_premultiply() } - /// Interpolate colors in without premultiplying alpha (so in unpremultiplied "straight" alpha space). + /// Interpolate colors without premultiplying alpha (in unpremultiplied "straight" alpha space). /// /// Note: this function doesn't fix up hue in cylindrical spaces. It is /// still useful if the hue angles are compatible, particularly if the