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
10hi_warning_push();
11// C26434: Function '...' hides a non-virtual function '...'.
12// We need to hide those functions.
13hi_warning_ignore_msvc(26434);
14
15namespace hi::inline v1 {
16
20struct sdf_r8 : public snorm_r8 {
26 constexpr static float max_distance = 3.0f;
27 constexpr static float one_over_max_distance = 1.0f / max_distance;
28
29 sdf_r8() noexcept = default;
30 sdf_r8(sdf_r8 const& other) noexcept = default;
31 sdf_r8(sdf_r8&& other) noexcept = default;
32 sdf_r8& operator=(sdf_r8 const& other) noexcept = default;
33 sdf_r8& operator=(sdf_r8&& other) noexcept = default;
34 ~sdf_r8() = default;
35
36 sdf_r8(float rhs) noexcept : snorm_r8(rhs * one_over_max_distance) {}
37
38 sdf_r8& operator=(float rhs) noexcept
39 {
40 snorm_r8::operator=(rhs *one_over_max_distance);
41 return *this;
42 }
43
44 operator float() const noexcept
45 {
46 return (snorm_r8::operator float()) * max_distance;
47 }
48
49 void repair() noexcept
50 {
51 *this = -static_cast<float>(*this);
52 }
53};
54
55} // namespace hi::inline v1
56
57hi_warning_pop();
A pixel of a single channel signed distance field.
Definition sdf_r8.hpp:20
Definition snorm_r8.hpp:17