The repository had no licence at all, so every source was all-rights-reserved by default. Add the verbatim MIT text at LICENSE (Copyright (c) 2026 Martino Ferrari) and a two-line SPDX header to each of the 113 first-party sources -- 48 include/plot, 26 src, 10 adapters, 5 examples, 21 tests, 3 tools -- so the grant travels with each file rather than relying on the root document alone. Scripts keep their shebang on line 1; the SPDX lines follow it. Genuinely vendored code is untouched: third_party/stb_truetype.h carries no header of ours. src/render/embedded_mono_font.cpp is generated, so tools/fonts/gen_atlas.py emit() now writes the two lines into its header comment and the file was regenerated -- gen_atlas.py --check passes and the regeneration adds only those comment lines to the previously committed file. README's provenance section now states MIT and links LICENSE. No code, test or public API change.
32 lines
912 B
C++
32 lines
912 B
C++
// SPDX-License-Identifier: MIT
|
|
// SPDX-FileCopyrightText: 2026 Martino Ferrari
|
|
|
|
#pragma once
|
|
#include <cmath>
|
|
#include <plot/core/types.hpp>
|
|
|
|
namespace plot::math {
|
|
|
|
/// 2D vector of `f32`, used for pixel offsets and normalised device coords.
|
|
struct Vec2 {
|
|
f32 x = 0.0f;
|
|
f32 y = 0.0f;
|
|
|
|
constexpr Vec2 operator+(const Vec2& o) const noexcept { return {x + o.x, y + o.y}; }
|
|
constexpr Vec2 operator-(const Vec2& o) const noexcept { return {x - o.x, y - o.y}; }
|
|
constexpr Vec2 operator*(f32 s) const noexcept { return {x * s, y * s}; }
|
|
constexpr Vec2 operator/(f32 s) const noexcept { return {x / s, y / s}; }
|
|
|
|
constexpr f32 dot(const Vec2& o) const noexcept { return x * o.x + y * o.y; }
|
|
|
|
f32 length() const noexcept { return std::sqrt(x * x + y * y); }
|
|
};
|
|
|
|
constexpr Vec2 operator*(f32 s, const Vec2& v) noexcept { return v * s; }
|
|
|
|
} // namespace plot::math
|
|
|
|
namespace plot {
|
|
using math::Vec2;
|
|
}
|