Hyprland/src/helpers/BezierCurve.hpp

27 lines
645 B
C++
Raw Normal View History

2022-04-23 21:47:16 +02:00
#pragma once
#include "../defines.hpp"
#include <deque>
2022-04-23 23:16:43 +02:00
constexpr int BAKEDPOINTS = 200;
constexpr float INVBAKEDPOINTS = 1.f / BAKEDPOINTS;
2022-04-23 21:47:16 +02:00
// an implementation of a cubic bezier curve
// might do better later
// TODO: n-point curves
class CBezierCurve {
public:
// sets up the bezier curve.
// this EXCLUDES the 0,0 and 1,1 points,
void setup(std::vector<Vector2D>* points);
float getYForT(float t);
float getXForT(float t);
float getYForPoint(float x);
private:
// this INCLUDES the 0,0 and 1,1 points.
std::deque<Vector2D> m_dPoints;
2022-05-12 16:59:51 +02:00
std::array<Vector2D, BAKEDPOINTS> m_aPointsBaked;
2022-04-23 21:47:16 +02:00
};