Path2D.h 981 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/RefCounted.h>
  8. #include <LibGfx/Path.h>
  9. #include <LibWeb/Bindings/PlatformObject.h>
  10. #include <LibWeb/Geometry/DOMMatrixReadOnly.h>
  11. #include <LibWeb/HTML/Canvas/CanvasPath.h>
  12. namespace Web::HTML {
  13. // https://html.spec.whatwg.org/multipage/canvas.html#path2d
  14. class Path2D final
  15. : public Bindings::PlatformObject
  16. , public CanvasPath {
  17. WEB_PLATFORM_OBJECT(Path2D, Bindings::PlatformObject);
  18. public:
  19. static WebIDL::ExceptionOr<JS::NonnullGCPtr<Path2D>> construct_impl(JS::Realm&, Optional<Variant<JS::Handle<Path2D>, String>> const& path);
  20. virtual ~Path2D() override;
  21. WebIDL::ExceptionOr<void> add_path(JS::NonnullGCPtr<Path2D> path, Geometry::DOMMatrix2DInit& transform);
  22. private:
  23. Path2D(JS::Realm&, Optional<Variant<JS::Handle<Path2D>, String>> const&);
  24. virtual void initialize(JS::Realm&) override;
  25. };
  26. }