1#ifndef TATOOINE_BEZIER_WIDGET
2#define TATOOINE_BEZIER_WIDGET
9#define IMGUI_DEFINE_MATH_OPERATORS
15auto BezierValue(
float dt01, std::vector<float>
const& handles) -> float;
17auto Bezier(
const char* label, std::vector<float>& handles) -> int;
20auto BezierTable(ImVec2 P[4], ImVec2 results[steps + 1]) ->
void {
21 static float C[(steps + 1) * 4], *K = 0;
24 for (
unsigned step = 0; step <= steps; ++step) {
25 float t = (float)step / (
float)steps;
26 C[step * 4 + 0] = (1 - t) * (1 - t) * (1 - t);
27 C[step * 4 + 1] = 3 * (1 - t) * (1 - t) * t;
28 C[step * 4 + 2] = 3 * (1 - t) * t * t;
29 C[step * 4 + 3] = t * t * t;
32 for (
unsigned step = 0; step <= steps; ++step) {
33 ImVec2 point = {K[step * 4 + 0] * P[0].x + K[step * 4 + 1] * P[1].x +
34 K[step * 4 + 2] * P[3].x + K[step * 4 + 3] * P[2].x,
35 K[step * 4 + 0] * P[0].y + K[step * 4 + 1] * P[1].y +
36 K[step * 4 + 2] * P[3].y + K[step * 4 + 3] * P[2].y};
37 results[step] = point;
Definition: bezier_widget.h:13
auto Bezier(const char *label, std::vector< float > &handles) -> int
auto BezierValue(float dt01, std::vector< float > const &handles) -> float
auto BezierTable(ImVec2 P[4], ImVec2 results[steps+1]) -> void
Definition: bezier_widget.h:20