mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:07:44 +00:00
LibWeb+LibGfx: Allow stroking with a paint style and opacity
This commit is contained in:
parent
eb4a58528e
commit
30c316a2bf
4 changed files with 16 additions and 4 deletions
|
@ -154,3 +154,14 @@
|
||||||
</defs>
|
</defs>
|
||||||
<rect x="115" y="15" width="170" height="110" stroke="url(#grad7)" fill="none" transform="rotate(45 200 70)" />
|
<rect x="115" y="15" width="170" height="110" stroke="url(#grad7)" fill="none" transform="rotate(45 200 70)" />
|
||||||
</svg>
|
</svg>
|
||||||
|
<br>
|
||||||
|
<b>Stroke linear gradient + transform with stroke-opacity</b><br>
|
||||||
|
<svg height="150" width="400">
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="grad7" x1="0" y1="0" x2="70%" y2="0">
|
||||||
|
<stop offset="0" stop-color="blue"/>
|
||||||
|
<stop offset="1" stop-color="magenta"/>
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
<rect x="115" y="15" width="170" height="110" stroke="url(#grad7)" stroke-opacity="0.5" stroke-width="10" fill="none" transform="rotate(5 200 70)" />
|
||||||
|
</svg>
|
||||||
|
|
|
@ -198,10 +198,10 @@ void AntiAliasingPainter::stroke_path(Path const& path, Color color, float thick
|
||||||
fill_path(path.stroke_to_fill(thickness), color);
|
fill_path(path.stroke_to_fill(thickness), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AntiAliasingPainter::stroke_path(Path const& path, Gfx::PaintStyle const& paint_style, float thickness)
|
void AntiAliasingPainter::stroke_path(Path const& path, Gfx::PaintStyle const& paint_style, float thickness, float opacity)
|
||||||
{
|
{
|
||||||
// FIXME: Cache this? Probably at a higher level such as in LibWeb?
|
// FIXME: Cache this? Probably at a higher level such as in LibWeb?
|
||||||
fill_path(path.stroke_to_fill(thickness), paint_style);
|
fill_path(path.stroke_to_fill(thickness), paint_style, opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AntiAliasingPainter::fill_rect(FloatRect const& float_rect, Color color)
|
void AntiAliasingPainter::fill_rect(FloatRect const& float_rect, Color color)
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
void fill_path(Path const&, PaintStyle const& paint_style, float opacity = 1.0f, Painter::WindingRule rule = Painter::WindingRule::Nonzero);
|
void fill_path(Path const&, PaintStyle const& paint_style, float opacity = 1.0f, Painter::WindingRule rule = Painter::WindingRule::Nonzero);
|
||||||
|
|
||||||
void stroke_path(Path const&, Color, float thickness);
|
void stroke_path(Path const&, Color, float thickness);
|
||||||
void stroke_path(Path const&, PaintStyle const& paint_style, float thickness);
|
void stroke_path(Path const&, PaintStyle const& paint_style, float thickness, float opacity = 1.0f);
|
||||||
|
|
||||||
void translate(float dx, float dy) { m_transform.translate(dx, dy); }
|
void translate(float dx, float dy) { m_transform.translate(dx, dy); }
|
||||||
void translate(FloatPoint delta) { m_transform.translate(delta); }
|
void translate(FloatPoint delta) { m_transform.translate(delta); }
|
||||||
|
|
|
@ -122,7 +122,8 @@ void SVGGeometryPaintable::paint(PaintContext& context, PaintPhase phase) const
|
||||||
painter.stroke_path(
|
painter.stroke_path(
|
||||||
path,
|
path,
|
||||||
*paint_style,
|
*paint_style,
|
||||||
stroke_thickness);
|
stroke_thickness,
|
||||||
|
stroke_opacity);
|
||||||
} else if (auto stroke_color = geometry_element.stroke_color().value_or(svg_context.stroke_color()).with_opacity(stroke_opacity); stroke_color.alpha() > 0) {
|
} else 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(
|
painter.stroke_path(
|
||||||
path,
|
path,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue