mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 18:24:45 -05:00
Color: Add interpolate method
This commit is contained in:
parent
ff76a5b8d2
commit
4233b69ecf
Notes:
sideshowbarker
2024-07-18 18:46:19 +09:00
Author: https://github.com/mattco98 Commit: https://github.com/SerenityOS/serenity/commit/4233b69ecf6 Pull-request: https://github.com/SerenityOS/serenity/pull/6524
1 changed files with 10 additions and 0 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <AK/SIMD.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <LibIPC/Forward.h>
|
||||
#include <math.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
|
@ -139,6 +140,15 @@ public:
|
|||
#endif
|
||||
}
|
||||
|
||||
constexpr Color interpolate(const Color& other, float weight) const
|
||||
{
|
||||
u8 r = red() + roundf(static_cast<float>(other.red() - red()) * weight);
|
||||
u8 g = green() + roundf(static_cast<float>(other.green() - green()) * weight);
|
||||
u8 b = blue() + roundf(static_cast<float>(other.blue() - blue()) * weight);
|
||||
u8 a = alpha() + roundf(static_cast<float>(other.alpha() - alpha()) * weight);
|
||||
return Color(r, g, b, a);
|
||||
}
|
||||
|
||||
constexpr Color multiply(const Color& other) const
|
||||
{
|
||||
return Color(
|
||||
|
|
Loading…
Add table
Reference in a new issue