Vector2.h 769 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2020, Stephan Unverwerth <s.unverwerth@serenityos.org>
  3. * Copyright (c) 2022, the SerenityOS developers.
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include "VectorN.h"
  9. #include <AK/Error.h>
  10. #include <AK/Format.h>
  11. #include <AK/StringView.h>
  12. namespace Gfx {
  13. template<class T>
  14. using Vector2 = VectorN<2, T>;
  15. using FloatVector2 = Vector2<float>;
  16. using DoubleVector2 = Vector2<double>;
  17. }
  18. namespace AK {
  19. template<typename T>
  20. struct Formatter<Gfx::Vector2<T>> : Formatter<StringView> {
  21. ErrorOr<void> format(FormatBuilder& builder, Gfx::Vector2<T> const& value)
  22. {
  23. return Formatter<StringView>::format(builder, value.to_string());
  24. }
  25. };
  26. }
  27. using Gfx::DoubleVector2;
  28. using Gfx::FloatVector2;
  29. using Gfx::Vector2;