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 tt {
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 :
32 snorm_r8(rhs * one_over_max_distance) {}
33
34 sdf_r8 &operator=(float rhs) noexcept {
35 snorm_r8::operator=(rhs * one_over_max_distance);
36 return *this;
37 }
38
39 operator float () const noexcept {
40 return (snorm_r8::operator float()) * max_distance;
41 }
42
43 void repair() noexcept {
44 *this = -static_cast<float>(*this);
45 }
46};
47
48}
A pixel of a single channel signed distance field.
Definition sdf_r8.hpp:15
static constexpr float max_distance
Max distance in pixels represented by the signed distance field.
Definition sdf_r8.hpp:21
Definition snorm_r8.hpp:17