MCPcopy Create free account
hub / github.com/Tencent/libpag / CaculateCubicLength

Function CaculateCubicLength

exporter/src/export/stream/StreamProperty.cpp:73–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73static float CaculateCubicLength(const BezierPoint* points, float distance, unsigned minT,
74 unsigned maxT, const float& precision) {
75 if (TSpanBigEnough(maxT - minT) && CubicTooCurvy(points, precision)) {
76 auto halfT = (minT + maxT) >> 1;
77 auto p1 = InterpolatePoint(points[0], points[1], 0.5);
78 auto bc = InterpolatePoint(points[1], points[2], 0.5);
79 auto p5 = InterpolatePoint(points[2], points[3], 0.5);
80 auto p2 = InterpolatePoint(p1, bc, 0.5);
81 auto p4 = InterpolatePoint(bc, p5, 0.5);
82 auto p3 = InterpolatePoint(p2, p4, 0.5);
83 BezierPoint result[7] = {points[0], p1, p2, p3, p4, p5, points[3]};
84 distance = CaculateCubicLength(result, distance, minT, halfT, precision);
85 distance = CaculateCubicLength(&result[3], distance, halfT, maxT, precision);
86 } else {
87 distance += Distance(points[0], points[3]);
88 }
89 return distance;
90}
91
92static bool PointOnLine(const float x1, const float y1, const float x2, const float y2,
93 const float x3, const float y3, const float& precision) {

Callers 1

GetCubicLengthFunction · 0.85

Calls 4

InterpolatePointFunction · 0.85
TSpanBigEnoughFunction · 0.70
CubicTooCurvyFunction · 0.70
DistanceFunction · 0.70

Tested by

no test coverage detected