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
16hi_export_module(hikogui.utility.numbers);
17
18hi_export namespace hi::inline v1 {
19
24template<typename T> requires (std::numeric_limits<T>::max() >= 16777215)
25constexpr auto large_number_v = T{16777215};
26
29template<std::floating_point T>
30constexpr auto points_per_inch_v = T{72.0};
31
41template<std::floating_point T>
42constexpr auto dp_per_inch_v = T{80.0};
43
44template<std::floating_point T>
45constexpr auto points_to_dp_scale_v = dp_per_inch_v<T> / points_per_inch_v<T>;
46
49template<std::floating_point T>
50constexpr T points_to_dp(T x) noexcept
51{
52 return x * points_to_dp_scale_v<T>;
53}
54
58
62
63} // namespace hi::inline v1
DOXYGEN BUG.
Definition algorithm.hpp:16
constexpr auto points_per_inch_v
The number of points (typography) per inch.
Definition numbers.hpp:30
constexpr auto dp_per_inch_v
The number of device independent pixels per inch.
Definition numbers.hpp:42
constexpr double points_per_inch
Definition numbers.hpp:57
constexpr double dp_per_inch
Definition numbers.hpp:61
constexpr T points_to_dp(T x) noexcept
Convert points to device independent pixels.
Definition numbers.hpp:50
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
T max(T... args)