HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
numbers.hpp
Go to the documentation of this file.
1// Copyright Take Vos 2021.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
10#pragma once
11
12#include "../macros.hpp"
13#include "concepts.hpp"
14#include <concepts>
15#include <limits>
16
17hi_export_module(hikogui.utility.numbers);
18
19hi_export namespace hi::inline v1 {
20
25template<typename T> requires (std::numeric_limits<T>::max() >= 16777215)
26constexpr auto large_number_v = T{16777215};
27
30template<std::floating_point T>
31constexpr auto points_per_inch_v = T{72.0};
32
42template<std::floating_point T>
43constexpr auto dp_per_inch_v = T{80.0};
44
45template<std::floating_point T>
46constexpr auto points_to_dp_scale_v = dp_per_inch_v<T> / points_per_inch_v<T>;
47
50template<std::floating_point T>
51constexpr T points_to_dp(T x) noexcept
52{
53 return x * points_to_dp_scale_v<T>;
54}
55
58constexpr double points_per_inch = points_per_inch_v<double>;
59
62constexpr double dp_per_inch = dp_per_inch_v<double>;
63
64} // namespace hi::inline v1
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
constexpr auto points_per_inch_v
The number of points (typography) per inch.
Definition numbers.hpp:31
constexpr auto dp_per_inch_v
The number of device independent pixels per inch.
Definition numbers.hpp:43
constexpr double points_per_inch
Definition numbers.hpp:58
constexpr double dp_per_inch
Definition numbers.hpp:62
constexpr T points_to_dp(T x) noexcept
Convert points to device independent pixels.
Definition numbers.hpp:51
T max(T... args)