GCC Code Coverage Report


Directory: ./
File: src/tide/bezier.h
Date: 2023-04-27 00:55:30
Exec Total Coverage
Lines: 0 4 0.0%
Functions: 0 1 0.0%
Branches: 0 0 -%

Line Branch Exec Source
1 //------------------------------------------------------------------------------
2 // VERSION 0.1
3 //
4 // LICENSE
5 // This software is dual-licensed to the public domain and under the following
6 // license: you are granted a perpetual, irrevocable license to copy, modify,
7 // publish, and distribute this file as you see fit.
8 //
9 // CREDITS
10 // Written by Michal Cichon
11 //------------------------------------------------------------------------------
12
13 #pragma
14
15 #define IMGUI_DEFINE_MATH_OPERATORS
16 #include <imgui.h>
17
18 // Project point on Cubic Bezier curve.
19 struct ImProjectResult
20 {
21 ImVec2 Point; // Point on curve
22 float Time; // [0 - 1]
23 float Distance; // Distance to curve
24 };
25
26
27 template <typename T>
28 inline T ImCubicBezier(const T& p0, const T& p1, const T& p2, const T& p3, float t)
29 {
30 const auto a = 1 - t;
31 const auto b = a * a * a;
32 const auto c = t * t * t;
33
34 return b * p0 + 3 * t * a * a * p1 + 3 * t * t * a * p2 + c * p3;
35 }
36
37 ImProjectResult ImProjectOnCubicBezier(const ImVec2& point, const ImVec2& p0, const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const int subdivisions);
38