划线
Processing 提供了一个名为 line() 的方法在屏幕上绘制一条线。此代码在黑色背景上绘制白色 10 像素线。
void setup() {
size(500, 500);
background(0);
stroke(255);
strokeWeight(10);
}
void draw() {
line(0, 0, 500, 500);
}
方法 line() 的签名就是这个。
line(x1, y1, x2, y2);
x1 和 y1 是起点的坐标。x2 和 y2 是终点的坐标。
方法 stroke() 用于指定要绘制的线条的颜色。
方法 strokeWeight() 用于指定要绘制的线条的粗细。 (以像素为单位)