名称:constrain()
例子:
void draw()
{
background(204);
float mx = constrain(mouseX, 30, 70);
rect(mx-10, 40, 20, 20);
}
描述:
限制一个值不超过最大值和最小值。
语法:
constrain(amt, low, high)
参数:
amt | int, or float: the value to constrain 被约束值 |
---|---|
low | int, or float: minimum limit 最小极限 |
high | int, or float: maximum limit 最大极限 |
返回:int or float
相关:
- 本文固定链接: http://iprocessing.cn/2017/07/13/constrain-约束/
- 转载请注明: Hewes 于 Processing编程艺术 发表