HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
sdf_r8.hpp
1// Copyright Take Vos 2020.
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
5#pragma once
6
7#include "snorm_r8.hpp"
8#include "../math.hpp"
9
10namespace hi::inline v1 {
11
15struct sdf_r8 : public snorm_r8 {
21 constexpr static float max_distance = 3.0f;
22 constexpr static float one_over_max_distance = 1.0f / max_distance;
23
24 sdf_r8() noexcept = default;
25 sdf_r8(sdf_r8 const &other) noexcept = default;
26 sdf_r8(sdf_r8 &&other) noexcept = default;
27 sdf_r8 &operator=(sdf_r8 const &other) noexcept = default;
28 sdf_r8 &operator=(sdf_r8 &&other) noexcept = default;
29 ~sdf_r8() = default;
30
31 sdf_r8(float rhs) noexcept : snorm_r8(rhs * one_over_max_distance) {}
32
33 sdf_r8 &operator=(float rhs) noexcept
34 {
35 snorm_r8::operator=(rhs *one_over_max_distance);
36 return *this;
37 }
38
39 operator float() const noexcept
40 {
41 return (snorm_r8::operator float()) * max_distance;
42 }
43
44 void repair() noexcept
45 {
46 *this = -static_cast<float>(*this);
47 }
48};
49
50} // namespace hi::inline v1
A pixel of a single channel signed distance field.
Definition sdf_r8.hpp:15
Definition snorm_r8.hpp:17