MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / smoothSpline

Function smoothSpline

libs/echarts/echarts.simple.js:15907–15948  ·  view source on GitHub ↗
(points, isLoop)

Source from the content-addressed store, hash-verified

15905 * @return {Array}
15906 */
15907var smoothSpline = function (points, isLoop) {
15908 var len$$1 = points.length;
15909 var ret = [];
15910
15911 var distance$$1 = 0;
15912 for (var i = 1; i < len$$1; i++) {
15913 distance$$1 += distance(points[i - 1], points[i]);
15914 }
15915
15916 var segs = distance$$1 / 2;
15917 segs = segs < len$$1 ? len$$1 : segs;
15918 for (var i = 0; i < segs; i++) {
15919 var pos = i / (segs - 1) * (isLoop ? len$$1 : len$$1 - 1);
15920 var idx = Math.floor(pos);
15921
15922 var w = pos - idx;
15923
15924 var p0;
15925 var p1 = points[idx % len$$1];
15926 var p2;
15927 var p3;
15928 if (!isLoop) {
15929 p0 = points[idx === 0 ? idx : idx - 1];
15930 p2 = points[idx > len$$1 - 2 ? len$$1 - 1 : idx + 1];
15931 p3 = points[idx > len$$1 - 3 ? len$$1 - 1 : idx + 2];
15932 }
15933 else {
15934 p0 = points[(idx - 1 + len$$1) % len$$1];
15935 p2 = points[(idx + 1) % len$$1];
15936 p3 = points[(idx + 2) % len$$1];
15937 }
15938
15939 var w2 = w * w;
15940 var w3 = w * w2;
15941
15942 ret.push([
15943 interpolate(p0[0], p1[0], p2[0], p3[0], w, w2, w3),
15944 interpolate(p0[1], p1[1], p2[1], p3[1], w, w2, w3)
15945 ]);
15946 }
15947 return ret;
15948};
15949
15950/**
15951 * 贝塞尔平滑曲线

Callers 1

buildPath$1Function · 0.70

Calls 3

pushMethod · 0.80
distanceFunction · 0.70
interpolateFunction · 0.70

Tested by

no test coverage detected