mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-28 05:52:53 +00:00
LibWeb: Implement SVG opacity properties
This implements the stop-opacity, fill-opacity, and stroke-opacity properties (in CSS). This replaces the existing more ad-hoc fill-opacity attribute handling.
This commit is contained in:
parent
120e5b6b6f
commit
00cda96e2d
Notes:
sideshowbarker
2024-07-16 21:51:02 +09:00
Author: https://github.com/MacDue
Commit: 00cda96e2d
Pull-request: https://github.com/SerenityOS/serenity/pull/18927
13 changed files with 141 additions and 29 deletions
|
@ -101,19 +101,22 @@ void SVGGeometryPaintable::paint(PaintContext& context, PaintPhase phase) const
|
|||
.transform = paint_transform
|
||||
};
|
||||
|
||||
// FIXME: Apply fill opacity to paint styles?
|
||||
auto fill_opacity = geometry_element.fill_opacity().value_or(svg_context.fill_opacity());
|
||||
if (auto paint_style = geometry_element.fill_paint_style(paint_context); paint_style.has_value()) {
|
||||
painter.fill_path(
|
||||
closed_path(),
|
||||
*paint_style,
|
||||
Gfx::Painter::WindingRule::EvenOdd);
|
||||
} else if (auto fill_color = geometry_element.fill_color().value_or(svg_context.fill_color()); fill_color.alpha() > 0) {
|
||||
} else if (auto fill_color = geometry_element.fill_color().value_or(svg_context.fill_color()).with_opacity(fill_opacity); fill_color.alpha() > 0) {
|
||||
painter.fill_path(
|
||||
closed_path(),
|
||||
fill_color,
|
||||
Gfx::Painter::WindingRule::EvenOdd);
|
||||
}
|
||||
|
||||
if (auto stroke_color = geometry_element.stroke_color().value_or(svg_context.stroke_color()); stroke_color.alpha() > 0) {
|
||||
auto stroke_opacity = geometry_element.stroke_opacity().value_or(svg_context.stroke_opacity());
|
||||
if (auto stroke_color = geometry_element.stroke_color().value_or(svg_context.stroke_color()).with_opacity(stroke_opacity); stroke_color.alpha() > 0) {
|
||||
painter.stroke_path(
|
||||
path,
|
||||
stroke_color,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue