Skip to content

Commit c4cf687

Browse files
committed
More goodies in Color
1 parent c5d5759 commit c4cf687

File tree

5 files changed

+489
-181
lines changed

5 files changed

+489
-181
lines changed

modules/yup_graphics/graphics/yup_Color.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -822,8 +822,14 @@ Color Color::mixedWith (Color other, float amount, ColorSpace space) const noexc
822822

823823
//==============================================================================
824824

825-
Color& Color::blendWith (Color src, BlendMode mode) noexcept
825+
Color& Color::blendWith (Color src, BlendMode mode, float opacity) noexcept
826826
{
827+
const float clampedOpacity = jlimit (0.0f, 1.0f, opacity);
828+
if (clampedOpacity <= 0.0f)
829+
return *this;
830+
831+
src = src.withMultipliedAlpha (clampedOpacity);
832+
827833
const double srcAlpha = src.getAlphaFloat();
828834
const double destAlpha = getAlphaFloat();
829835

@@ -870,10 +876,10 @@ Color& Color::blendWith (Color src, BlendMode mode) noexcept
870876
return *this;
871877
}
872878

873-
Color Color::blendedWith (Color src, BlendMode mode) const noexcept
879+
Color Color::blendedWith (Color src, BlendMode mode, float opacity) const noexcept
874880
{
875881
Color result (*this);
876-
result.blendWith (src, mode);
882+
result.blendWith (src, mode, opacity);
877883
return result;
878884
}
879885

0 commit comments

Comments
 (0)