首页 > 文档 > lerp()
2017
07-18

lerp()

名称:lerp()

 

例子:

lerp() - 第1张  | Processing编程艺术

float a = 20;
float b = 80;
float c = lerp(a, b, .2);
float d = lerp(a, b, .5);
float e = lerp(a, b, .8);
beginShape(POINTS);
vertex(a, 50);
vertex(b, 50);
vertex(c, 50);
vertex(d, 50);
vertex(e, 50);
endShape();

lerp() - 第2张  | Processing编程艺术

int x1 = 15;
int y1 = 10;
int x2 = 80;
int y2 = 90;
line(x1, y1, x2, y2);
for (int i = 0; i <= 10; i++) {
float x = lerp(x1, x2, i/10.0) + 10;
float y = lerp(y1, y2, i/10.0);
point(x, y);
}

 

描述:

以特定增量计算两个数字之间的数字。 amt参数是在两个值之间插值的量,其中0.0等于第一点,0.1非常接近第一点,0.5是中间值等等。lerp函数便于沿着直线路径创建运动 并绘制虚线。

 

语法:

lerp(start, stop, amt)

 

参数:

start float: first value              起始值
stop float: second value         第二个值
amt float: float between 0.0 and 1.0       0.0到1.0之间的浮点数

返回:float

 

相关:

curvePoint()
bezierPoint()
lerp()
lerpColor()



最后编辑:
作者:Hewes
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。