Ratio.h 500 B

123456789101112131415161718192021222324252627
  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/String.h>
  8. namespace Web::CSS {
  9. // https://www.w3.org/TR/css-values-4/#ratios
  10. class Ratio {
  11. public:
  12. Ratio(float first, float second = 1);
  13. float value() const { return m_first_value / m_second_value; }
  14. bool is_degenerate() const;
  15. ErrorOr<String> to_string() const;
  16. private:
  17. float m_first_value { 0 };
  18. float m_second_value { 1 };
  19. };
  20. }