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 be5a07a..2d0bfba 100644 --- a/color/src/color.rs +++ b/color/src/color.rs @@ -475,6 +475,16 @@ impl AlphaColor { .un_premultiply() } + /// 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 + /// 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 {