名称:dist()
例子:
// Sets the background gray value based on the distance
// of the mouse from the center of the screen
void draw() {
noStroke();
float d = dist(width/2, height/2, mouseX, mouseY);
float maxDist = dist(0, 0, width/2, height/2);
float gray = map(d, 0, maxDist, 0, 255);
fill(gray);
rect(0, 0, width, height);
}
描述:
计算两点之间的距离。
语法:
dist(x1, y1, x2, y2) dist(x1, y1, z1, x2, y2, z2)
参数:
|
返回:float
- 本文固定链接: http://iprocessing.cn/2017/07/13/dist-距离/
- 转载请注明: Hewes 于 Processing编程艺术 发表
Pingback 引用通告: mag() 向量大小 | Processing编程艺术