1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:58:12 +00:00

LibWeb: Update CRC2D .fillStyle and .strokeStyle to accept gradients

While doing add some structures to hold these new fill styles and
plumb them over to the painter.
This commit is contained in:
MacDue 2023-01-18 20:10:00 +01:00 committed by Andreas Kling
parent 2be4142138
commit 24cb57ac88
5 changed files with 89 additions and 17 deletions

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
* Copyright (c) 2023, MacDue <macdue@dueutil.tech>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -39,4 +40,21 @@ bool CanvasState::is_context_lost()
return m_context_lost;
}
NonnullRefPtr<Gfx::PaintStyle> CanvasState::FillOrStrokeStyle::to_gfx_paint_style()
{
VERIFY_NOT_REACHED();
}
Gfx::Color CanvasState::FillOrStrokeStyle::to_color_but_fixme_should_accept_any_paint_style() const
{
return as_color().value_or(Gfx::Color::Black);
}
Optional<Gfx::Color> CanvasState::FillOrStrokeStyle::as_color() const
{
if (auto* color = m_fill_or_stoke_style.get_pointer<Gfx::Color>())
return *color;
return {};
}
}