MCPcopy
hub / github.com/tdewolff/minify / buildLabelLinePath

Function buildLabelLinePath

_benchmarks/sample_echarts.js:25173–25204  ·  view source on GitHub ↗
(path, shape)

Source from the content-addressed store, hash-verified

25171 }
25172
25173 function buildLabelLinePath(path, shape) {
25174 var smooth = shape.smooth;
25175 var points = shape.points;
25176
25177 if (!points) {
25178 return;
25179 }
25180
25181 path.moveTo(points[0][0], points[0][1]);
25182
25183 if (smooth > 0 && points.length >= 3) {
25184 var len1 = dist(points[0], points[1]);
25185 var len2 = dist(points[1], points[2]);
25186
25187 if (!len1 || !len2) {
25188 path.lineTo(points[1][0], points[1][1]);
25189 path.lineTo(points[2][0], points[2][1]);
25190 return;
25191 }
25192
25193 var moveLen = Math.min(len1, len2) * smooth;
25194 var midPoint0 = lerp([], points[1], points[0], moveLen / len1);
25195 var midPoint2 = lerp([], points[1], points[2], moveLen / len2);
25196 var midPoint1 = lerp([], midPoint0, midPoint2, 0.5);
25197 path.bezierCurveTo(midPoint0[0], midPoint0[1], midPoint0[0], midPoint0[1], midPoint1[0], midPoint1[1]);
25198 path.bezierCurveTo(midPoint2[0], midPoint2[1], midPoint2[0], midPoint2[1], points[2][0], points[2][1]);
25199 } else {
25200 for (var i = 1; i < points.length; i++) {
25201 path.lineTo(points[i][0], points[i][1]);
25202 }
25203 }
25204 }
25205 /**
25206 * Create a label line if necessary and set it's style.
25207 */

Callers

nothing calls this directly

Calls 2

distFunction · 0.85
lerpFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…