HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
sdf_r8.hpp
Go to the documentation of this file.
1// Copyright Take Vos 2020-2022.
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
9#pragma once
10
11#include "snorm_r8.hpp"
12#include "../utility/module.hpp"
13
14hi_warning_push();
15// C26434: Function '...' hides a non-virtual function '...'.
16// We need to hide those functions.
17hi_warning_ignore_msvc(26434);
18
19namespace hi::inline v1 {
20
26struct sdf_r8 : public snorm_r8 {
32 constexpr static float max_distance = 3.0f;
33 constexpr static float one_over_max_distance = 1.0f / max_distance;
34
35 sdf_r8() noexcept = default;
36 sdf_r8(sdf_r8 const& other) noexcept = default;
37 sdf_r8(sdf_r8&& other) noexcept = default;
38 sdf_r8& operator=(sdf_r8 const& other) noexcept = default;
39 sdf_r8& operator=(sdf_r8&& other) noexcept = default;
40 ~sdf_r8() = default;
41
42 sdf_r8(float rhs) noexcept : snorm_r8(rhs * one_over_max_distance) {}
43
44 sdf_r8& operator=(float rhs) noexcept
45 {
46 snorm_r8::operator=(rhs *one_over_max_distance);
47 return *this;
48 }
49
50 operator float() const noexcept
51 {
52 return (snorm_r8::operator float()) * max_distance;
53 }
54
55 void repair() noexcept
56 {
57 *this = -static_cast<float>(*this);
58 }
59};
60
61} // namespace hi::inline v1
62
63hi_warning_pop();
Defines the snorm_r8.
DOXYGEN BUG.
Definition algorithm.hpp:13
A pixel of a single channel signed distance field.
Definition sdf_r8.hpp:26
1 x int8_t pixel format.
Definition snorm_r8.hpp:25