mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:58:11 +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:
parent
24cb57ac88
commit
27a3e11f02
4 changed files with 26 additions and 38 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue