-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtility.hpp
69 lines (53 loc) · 1.17 KB
/
Utility.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#pragma once
#include <optional>
#include <compare>
#include <concepts>
#include "Settings.hpp"
#define HSV_(h, s, v) \
HSV \
{ \
h, s / 100.0, v / 100.0 \
}
namespace tomolatoon
{
template <class T>
using Optional = std::optional<T>;
constexpr double Sign(double d) noexcept
{
return (int)(d > 0) - (int)(d < 0);
}
constexpr double rSign(double d) noexcept
{
return -1 * Sign(d);
}
bool isURL(FilePathView fp) noexcept;
template <class T, std::equality_comparable_with<T> U, std::convertible_to<T> V>
T getOpt(T&& val, const U& error, V&& insted) noexcept(noexcept(val == error))
{
if (val == error)
return std::forward<V>(insted);
else
return std::forward<T>(val);
}
template <std::floating_point F>
F modulo(F val, F mod)
{
if (mod)
{
return val > 0 ? Fmod(val, mod) : mod + Fmod(val, mod);
}
else
{
return val;
}
}
namespace Cursor
{
void Update() noexcept;
Point Delta() noexcept;
Vec2 DeltaF() noexcept;
Vec2 Velocity() noexcept;
Vec2 PreviousVelocity() noexcept;
Vec2 Acceleration() noexcept;
} // namespace Cursor
} // namespace tomolatoon