1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 09:34:57 +09:00

LibWeb+LibGfx: Refactor CSS filters into LibGfx

CSS filters work similarly to canvas filters, so it makes sense to have
Gfx::Filter that can be used by both libraries in an analogous way
as Gfx::Color.
This commit is contained in:
Lucien Fiorini 2024-12-18 11:34:25 +01:00 committed by Alexander Kalenik
parent bc971a4ccc
commit 9fd1223992
Notes: github-actions[bot] 2024-12-18 17:55:46 +00:00
18 changed files with 365 additions and 367 deletions

43
Libraries/LibGfx/Filter.h Normal file
View file

@ -0,0 +1,43 @@
/*
* Copyright (c) 2024, Lucien Fiorini <lucienfiorini@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Variant.h>
#include <LibGfx/Color.h>
namespace Gfx {
struct BlurFilter {
float radius;
};
struct DropShadowFilter {
float offset_x;
float offset_y;
float radius;
Gfx::Color color;
};
struct HueRotateFilter {
float angle_degrees;
};
struct ColorFilter {
enum class Type {
Brightness,
Contrast,
Grayscale,
Invert,
Opacity,
Saturate,
Sepia
} type;
float amount;
};
using Filter = Variant<BlurFilter, DropShadowFilter, HueRotateFilter, ColorFilter>;
}