mirror of
https://github.com/RGBCube/serenity
synced 2025-07-29 15:07:45 +00:00
LibWeb+LibGfx: Allow filling with a paint style and opacity
This commit is contained in:
parent
8bd68198d6
commit
eb4a58528e
8 changed files with 32 additions and 12 deletions
|
@ -40,7 +40,7 @@ ErrorOr<void> CanvasPathClipper::apply_clip(Gfx::Painter& painter)
|
|||
painter.blit(actual_save_rect.location(), *m_saved_clip_region, m_saved_clip_region->rect(), 1.0f, false);
|
||||
Gfx::AntiAliasingPainter aa_painter { painter };
|
||||
auto fill_offset = m_bounding_box.location() - actual_save_rect.location();
|
||||
aa_painter.fill_path(m_canvas_clip.path, TRY(Gfx::BitmapPaintStyle::create(clip_area, fill_offset)), m_canvas_clip.winding_rule);
|
||||
aa_painter.fill_path(m_canvas_clip.path, TRY(Gfx::BitmapPaintStyle::create(clip_area, fill_offset)), 1.0f, m_canvas_clip.winding_rule);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -272,7 +272,7 @@ void CanvasRenderingContext2D::fill_internal(Gfx::Path& path, StringView fill_ru
|
|||
if (auto color = drawing_state.fill_style.as_color(); color.has_value()) {
|
||||
painter.fill_path(path, *color, fill_rule);
|
||||
} else {
|
||||
painter.fill_path(path, drawing_state.fill_style.to_gfx_paint_style(), fill_rule);
|
||||
painter.fill_path(path, drawing_state.fill_style.to_gfx_paint_style(), 1.0f, fill_rule);
|
||||
}
|
||||
return path.bounding_box();
|
||||
});
|
||||
|
|
|
@ -99,12 +99,12 @@ 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,
|
||||
fill_opacity,
|
||||
Gfx::Painter::WindingRule::EvenOdd);
|
||||
} 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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue