首页 > 文档 > lerpColor()线性颜色
2017
08-08

lerpColor()线性颜色

Name

lerpColor()线性颜色

   

Examples

lerpColor()线性颜色 - 第1张  | Processing编程艺术lerpColor()线性颜色 - 第2张  | Processing编程艺术lerpColor()线性颜色 - 第3张  | Processing编程艺术

stroke(255);

background(51);

color from = color(204, 102, 0);

color to = color(0, 102, 153);

color interA = lerpColor(from, to, .33);

color interB = lerpColor(from, to, .66);

fill(from);

rect(10, 20, 20, 60);

fill(interA);

rect(30, 20, 20, 60);

fill(interB);

rect(50, 20, 20, 60);

fill(to);

rect(70, 20, 20, 60);

Description

Calculates a color or colors between two color at a specific increment. The amt parameter is the amount to interpolate between the two values where 0.0 equal to the first point, 0.1 is very near the first point, 0.5 is halfway in between, etc. 
An amount below 0 will be treated as 0. Likewise, amounts above 1 will be capped at 1. This is different from the behavior of lerp(), but necessary because otherwise numbers outside the range will produce strange and unexpected colors.

在特定增量中计算两种颜色之间的颜色或颜色。amt 参数是在两个值之间插补的量, 其中0.0 等于第一个点, 0.1 是非常接近第一点, 0.5 是介于中间, 等等。

低于0的金额将被视为0。同样, 1 以上的金额将封顶1。这与 lerp () 的行为不同, 但有必要, 因为在范围之外的数字会产生奇怪的和意想不到的颜色。

Syntax

lerpColor(c1, c2, amt)

Parameters

c1

int: interpolate from this color

 

从这个颜色插值

c2

int: interpolate to this color

 插入到这种颜色

amt

float: between 0.0 and 1.0

在0和1之间

Returns

int

Related

color()
lerp()



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

留下一个回复

你的email不会被公开。