HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
SDF8.hpp
1// Copyright 2019 Pokitec
2// All rights reserved.
3
4#pragma once
5
6#include "TTauri/Foundation/R8SNorm.hpp"
7#include "TTauri/Foundation/math.hpp"
8
9namespace tt {
10
14struct SDF8 : public R8SNorm {
20 constexpr static float max_distance = 3.0f;
21 constexpr static float one_over_max_distance = 1.0f / max_distance;
22
23 SDF8() noexcept = default;
24 SDF8(SDF8 const &other) noexcept = default;
25 SDF8(SDF8 &&other) noexcept = default;
26 SDF8 &operator=(SDF8 const &other) noexcept = default;
27 SDF8 &operator=(SDF8 &&other) noexcept = default;
28 ~SDF8() = default;
29
30 SDF8(float rhs) noexcept :
31 R8SNorm(rhs * one_over_max_distance) {}
32
33 SDF8 &operator=(float rhs) noexcept {
34 R8SNorm::operator=(rhs * one_over_max_distance);
35 return *this;
36 }
37
38 operator float () const noexcept {
39 return (R8SNorm::operator float()) * max_distance;
40 }
41
42 void repair() noexcept {
43 *this = -static_cast<float>(*this);
44 }
45};
46
47}
Definition R8SNorm.hpp:16
A pixel of a single channel signed distance field.
Definition SDF8.hpp:14
static constexpr float max_distance
Max distance in pixels represented by the signed distance field.
Definition SDF8.hpp:20