Path2D.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/HTML/Path2D.h>
  7. namespace Web::HTML {
  8. // https://html.spec.whatwg.org/multipage/canvas.html#dom-path2d
  9. Path2D::Path2D(Optional<Variant<NonnullRefPtr<Path2D>, String>> const& path)
  10. {
  11. // 1. Let output be a new Path2D object.
  12. // 2. If path is not given, then return output.
  13. if (!path.has_value())
  14. return;
  15. // 3. If path is a Path2D object, then add all subpaths of path to output and return output.
  16. // (In other words, it returns a copy of the argument.)
  17. if (path->has<NonnullRefPtr<Path2D>>()) {
  18. this->path() = path->get<NonnullRefPtr<Path2D>>()->path();
  19. return;
  20. }
  21. dbgln("TODO: Implement constructing Path2D object with an SVG path string");
  22. // FIXME: 4. Let svgPath be the result of parsing and interpreting path according to SVG 2's rules for path data. [SVG]
  23. // FIXME: 5. Let (x, y) be the last point in svgPath.
  24. // FIXME: 6. Add all the subpaths, if any, from svgPath to output.
  25. // FIXME: 7. Create a new subpath in output with (x, y) as the only point in the subpath.
  26. // FIXME: 8. Return output.
  27. }
  28. }