Closely mimics ImBezierCubicClosestPointCasteljau() in imgui.cpp
| 1235 | |
| 1236 | // Closely mimics ImBezierCubicClosestPointCasteljau() in imgui.cpp |
| 1237 | static void PathBezierCubicCurveToCasteljau(ImVector<ImVec2>* path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level) |
| 1238 | { |
| 1239 | float dx = x4 - x1; |
| 1240 | float dy = y4 - y1; |
| 1241 | float d2 = (x2 - x4) * dy - (y2 - y4) * dx; |
| 1242 | float d3 = (x3 - x4) * dy - (y3 - y4) * dx; |
| 1243 | d2 = (d2 >= 0) ? d2 : -d2; |
| 1244 | d3 = (d3 >= 0) ? d3 : -d3; |
| 1245 | if ((d2 + d3) * (d2 + d3) < tess_tol * (dx * dx + dy * dy)) |
| 1246 | { |
| 1247 | path->push_back(ImVec2(x4, y4)); |
| 1248 | } |
| 1249 | else if (level < 10) |
| 1250 | { |
| 1251 | float x12 = (x1 + x2) * 0.5f, y12 = (y1 + y2) * 0.5f; |
| 1252 | float x23 = (x2 + x3) * 0.5f, y23 = (y2 + y3) * 0.5f; |
| 1253 | float x34 = (x3 + x4) * 0.5f, y34 = (y3 + y4) * 0.5f; |
| 1254 | float x123 = (x12 + x23) * 0.5f, y123 = (y12 + y23) * 0.5f; |
| 1255 | float x234 = (x23 + x34) * 0.5f, y234 = (y23 + y34) * 0.5f; |
| 1256 | float x1234 = (x123 + x234) * 0.5f, y1234 = (y123 + y234) * 0.5f; |
| 1257 | PathBezierCubicCurveToCasteljau(path, x1, y1, x12, y12, x123, y123, x1234, y1234, tess_tol, level + 1); |
| 1258 | PathBezierCubicCurveToCasteljau(path, x1234, y1234, x234, y234, x34, y34, x4, y4, tess_tol, level + 1); |
| 1259 | } |
| 1260 | } |
| 1261 | |
| 1262 | static void PathBezierQuadraticCurveToCasteljau(ImVector<ImVec2>* path, float x1, float y1, float x2, float y2, float x3, float y3, float tess_tol, int level) |
| 1263 | { |
no test coverage detected