lyb-js 1.6.39 → 1.6.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -22,4 +22,4 @@ export interface LibJsPiecewiseLerpPoint {
|
|
|
22
22
|
* console.log(LibJsPiecewiseLerp(points, 9, 0)); // 65
|
|
23
23
|
* @link 使用方法:https://www.npmjs.com/package/lyb-js#libjspiecewiselerp-分段线性插值
|
|
24
24
|
*/
|
|
25
|
-
export declare const
|
|
25
|
+
export declare const libJsPiecewiseLerp: (points: LibJsPiecewiseLerpPoint[], currentValue: number, edgeValue: number) => number;
|
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
* console.log(LibJsPiecewiseLerp(points, 9, 0)); // 65
|
|
16
16
|
* @link 使用方法:https://www.npmjs.com/package/lyb-js#libjspiecewiselerp-分段线性插值
|
|
17
17
|
*/
|
|
18
|
-
export const
|
|
18
|
+
export const libJsPiecewiseLerp = (points, currentValue, edgeValue) => {
|
|
19
19
|
if (!points.length)
|
|
20
20
|
return edgeValue;
|
|
21
|
-
if (currentValue < points[0].h ||
|
|
21
|
+
if (currentValue < points[0].h ||
|
|
22
|
+
currentValue >= points[points.length - 1].h) {
|
|
22
23
|
return edgeValue;
|
|
23
24
|
}
|
|
24
25
|
for (let i = 0; i < points.length - 1; i++) {
|