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/utility.hpp"
13#include "../macros.hpp"
14#include <bit>
15#include <cstdint>
16
17hi_export_module(hikogui.image.sdf_r8);
18
19hi_warning_push();
20// C26434: Function '...' hides a non-virtual function '...'.
21// We need to hide those functions.
22hi_warning_ignore_msvc(26434);
23
24hi_export namespace hi::inline v1 {
25
31struct sdf_r8 : public snorm_r8 {
37 constexpr static float max_distance = 3.0f;
38 constexpr static float one_over_max_distance = 1.0f / max_distance;
39
40 sdf_r8() noexcept = default;
41 sdf_r8(sdf_r8 const& other) noexcept = default;
42 sdf_r8(sdf_r8&& other) noexcept = default;
43 sdf_r8& operator=(sdf_r8 const& other) noexcept = default;
44 sdf_r8& operator=(sdf_r8&& other) noexcept = default;
45 ~sdf_r8() = default;
46
47 sdf_r8(float rhs) noexcept : snorm_r8(rhs * one_over_max_distance) {}
48
49 sdf_r8& operator=(float rhs) noexcept
50 {
51 snorm_r8::operator=(rhs *one_over_max_distance);
52 return *this;
53 }
54
55 operator float() const noexcept
56 {
57 return (snorm_r8::operator float()) * max_distance;
58 }
59
60 void repair() noexcept
61 {
62 *this = -static_cast<float>(*this);
63 }
64};
65
66} // namespace hi::inline v1
67
68hi_warning_pop();
Defines the snorm_r8.
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
A pixel of a single channel signed distance field.
Definition sdf_r8.hpp:31
1 x int8_t pixel format.
Definition snorm_r8.hpp:31