簡單的介紹如何在 Processing 使用line()來畫線,

用stroke()函數來設定顏色,

用strokeWeight()函數來設定線的粗細,

lin()函數的介紹:

Syntax line(x1, y1, x2, y2) line(x1, y1, z1, x2, y2, z2)
Parameters
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void setup()
{
//set window size
size(400,300);
//set initial background
background(255);
}

void draw()
{
//draw the line
stroke(255,0,0);
//default
strokeWeight(1);
line(50,50,200,200);
stroke(0,255,0);
//thicker
strokeWeight(4);
line(200,200,350,50);
}

圖形顯示

processing_lin.jpg