mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-01 06:07:59 +00:00
LibWeb: Implement the canvas gradients
This gets: - CanvasRenderingContext2D.createLinearGradient() - CanvasRenderingContext2D.createConicGradient() - CanvasRenderingContext2D.createRadialGradient() Actually working as fill styles for paths and rectangles :^) Getting them working for strokes is left as an exercise is left as an exercise for the reader.
This commit is contained in:
@@ -42,7 +42,15 @@ bool CanvasState::is_context_lost()
|
||||
|
||||
NonnullRefPtr<Gfx::PaintStyle> CanvasState::FillOrStrokeStyle::to_gfx_paint_style()
|
||||
{
|
||||
VERIFY_NOT_REACHED();
|
||||
return m_fill_or_stoke_style.visit(
|
||||
[&](Gfx::Color color) -> NonnullRefPtr<Gfx::PaintStyle> {
|
||||
if (!m_color_paint_style)
|
||||
m_color_paint_style = Gfx::SolidColorPaintStyle::create(color);
|
||||
return m_color_paint_style.release_nonnull();
|
||||
},
|
||||
[&](JS::Handle<CanvasGradient> gradient) {
|
||||
return gradient->to_gfx_paint_style();
|
||||
});
|
||||
}
|
||||
|
||||
Gfx::Color CanvasState::FillOrStrokeStyle::to_color_but_fixme_should_accept_any_paint_style() const
|
||||
|
||||
Reference in New Issue
Block a user