SVGRadialGradientElement.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c) 2023, MacDue <macdue@dueutil.tech>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/SVG/AttributeParser.h>
  8. #include <LibWeb/SVG/SVGAnimatedLength.h>
  9. #include <LibWeb/SVG/SVGGradientElement.h>
  10. namespace Web::SVG {
  11. class SVGRadialGradientElement : public SVGGradientElement {
  12. WEB_PLATFORM_OBJECT(SVGRadialGradientElement, SVGGradientElement);
  13. JS_DECLARE_ALLOCATOR(SVGRadialGradientElement);
  14. public:
  15. virtual ~SVGRadialGradientElement() override = default;
  16. virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
  17. virtual Optional<Gfx::PaintStyle const&> to_gfx_paint_style(SVGPaintContext const&) const override;
  18. JS::NonnullGCPtr<SVGAnimatedLength> cx() const;
  19. JS::NonnullGCPtr<SVGAnimatedLength> cy() const;
  20. JS::NonnullGCPtr<SVGAnimatedLength> fx() const;
  21. JS::NonnullGCPtr<SVGAnimatedLength> fy() const;
  22. JS::NonnullGCPtr<SVGAnimatedLength> fr() const;
  23. JS::NonnullGCPtr<SVGAnimatedLength> r() const;
  24. protected:
  25. SVGRadialGradientElement(DOM::Document&, DOM::QualifiedName);
  26. virtual void initialize(JS::Realm&) override;
  27. private:
  28. JS::GCPtr<SVGRadialGradientElement const> linked_radial_gradient() const
  29. {
  30. if (auto gradient = linked_gradient(); gradient && is<SVGRadialGradientElement>(*gradient))
  31. return &verify_cast<SVGRadialGradientElement>(*gradient);
  32. return {};
  33. }
  34. NumberPercentage start_circle_x() const;
  35. NumberPercentage start_circle_y() const;
  36. NumberPercentage start_circle_radius() const;
  37. NumberPercentage end_circle_x() const;
  38. NumberPercentage end_circle_y() const;
  39. NumberPercentage end_circle_radius() const;
  40. Optional<NumberPercentage> m_cx;
  41. Optional<NumberPercentage> m_cy;
  42. Optional<NumberPercentage> m_fx;
  43. Optional<NumberPercentage> m_fy;
  44. Optional<NumberPercentage> m_fr;
  45. Optional<NumberPercentage> m_r;
  46. mutable RefPtr<Gfx::SVGRadialGradientPaintStyle> m_paint_style;
  47. };
  48. }