CanvasDrawImage.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/HTML/HTMLCanvasElement.h>
  8. #include <LibWeb/HTML/HTMLImageElement.h>
  9. #include <LibWeb/WebIDL/ExceptionOr.h>
  10. namespace Web::HTML {
  11. // https://html.spec.whatwg.org/multipage/canvas.html#canvasimagesource
  12. // NOTE: This is the Variant created by the IDL wrapper generator, and needs to be updated accordingly.
  13. using CanvasImageSource = Variant<JS::Handle<HTMLImageElement>, JS::Handle<HTMLCanvasElement>>;
  14. // https://html.spec.whatwg.org/multipage/canvas.html#canvasdrawimage
  15. class CanvasDrawImage {
  16. public:
  17. virtual ~CanvasDrawImage() = default;
  18. WebIDL::ExceptionOr<void> draw_image(CanvasImageSource const&, float destination_x, float destination_y);
  19. WebIDL::ExceptionOr<void> draw_image(CanvasImageSource const&, float destination_x, float destination_y, float destination_width, float destination_height);
  20. WebIDL::ExceptionOr<void> draw_image(CanvasImageSource const&, float source_x, float source_y, float source_width, float source_height, float destination_x, float destination_y, float destination_width, float destination_height);
  21. virtual WebIDL::ExceptionOr<void> draw_image_internal(CanvasImageSource const&, float source_x, float source_y, float source_width, float source_height, float destination_x, float destination_y, float destination_width, float destination_height) = 0;
  22. protected:
  23. CanvasDrawImage() = default;
  24. };
  25. }