function smoothstep(x, min, max) {
if ( x <= min ) return 0;
if ( x >= max ) return 1;
x = ( x - min ) / ( max - min );
return x;
};
// 执行
smoothstep(100, 0, 200); // 0.5
smoothstep(100, -100, 200); // 0.6666666666666666
smoothstep(100, -100, 250); // 0.5714285714285714
javascript 计算插值(smoothstep )
最新推荐文章于 2023-10-23 14:11:55 发布