Skip to content

Commit

Permalink
ColorExtensions - Added 'BlendMode.Overlay'
Browse files Browse the repository at this point in the history
  • Loading branch information
NessieHax committed Aug 6, 2023
1 parent cc110af commit b027cd9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion PCK-Studio/Extensions/BlendMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ internal enum BlendMode
Average,
DescendingOrder,
AscendingOrder,
Screen
Screen,
Overlay
}
}
1 change: 1 addition & 0 deletions PCK-Studio/Extensions/ColorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ internal static byte BlendValues(float source, float overlay, BlendMode blendTyp
BlendMode.AscendingOrder => source > overlay ? overlay : source,
BlendMode.DescendingOrder => source < overlay ? overlay : source,
BlendMode.Screen => 1f - (1f - source) * (1f - overlay),
BlendMode.Overlay => source < 0.5f ? 2f * source * overlay : 1f - 2f * (1f - source) * (1f - overlay),
_ => 0.0f
};
return (byte)MathExtensions.Clamp(resultValue * 255, 0, 255);
Expand Down

0 comments on commit b027cd9

Please sign in to comment.