mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 03:07:35 +00:00
LibGfx: Implement PaintStyle for SVG linear gradients
This commit is contained in:
parent
71938550fa
commit
89d3c6d718
2 changed files with 96 additions and 14 deletions
|
@ -243,4 +243,49 @@ private:
|
|||
float m_end_radius { 0.0f };
|
||||
};
|
||||
|
||||
// The following paint styles implement the gradients required for SVGs
|
||||
|
||||
class SVGGradientPaintStyle : public GradientPaintStyle {
|
||||
public:
|
||||
void set_gradient_transform(Gfx::AffineTransform transform)
|
||||
{
|
||||
m_gradient_transform = transform;
|
||||
}
|
||||
|
||||
Optional<Gfx::AffineTransform> const& gradient_transform() const { return m_gradient_transform; }
|
||||
|
||||
private:
|
||||
Optional<Gfx::AffineTransform> m_gradient_transform {};
|
||||
};
|
||||
|
||||
class SVGLinearGradientPaintStyle final : public SVGGradientPaintStyle {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<SVGLinearGradientPaintStyle>> create(FloatPoint p0, FloatPoint p1)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) SVGLinearGradientPaintStyle(p0, p1));
|
||||
}
|
||||
|
||||
void set_start_point(FloatPoint start_point)
|
||||
{
|
||||
m_p0 = start_point;
|
||||
}
|
||||
|
||||
void set_end_point(FloatPoint end_point)
|
||||
{
|
||||
m_p1 = end_point;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void paint(IntRect physical_bounding_box, PaintFunction paint) const override;
|
||||
|
||||
SVGLinearGradientPaintStyle(FloatPoint p0, FloatPoint p1)
|
||||
: m_p0(p0)
|
||||
, m_p1(p1)
|
||||
{
|
||||
}
|
||||
|
||||
FloatPoint m_p0;
|
||||
FloatPoint m_p1;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue