数学
3. 向量
3.23. 向量欧式距离ab
dist()
示例:
let x = 0;
function setup() {
createCanvas(100, 100);
}
function draw() {
background(204);
x = x + 0.1;
if (x > width) {
x = 0;
}
line(x, 0, x, height);
}
function mousePressed() {
noLoop();
}
function mouseReleased() {
loop();
}
舞台区显示的画布内容如下:
![](https://course.juguandian.com/pluginfile.php/590/mod_book/chapter/166/01%E8%88%9E%E5%8F%B00106noloop02_canvas.jpg)