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

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

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

lin()函數的介紹:

Syntax
line(x1, y1, x2, y2)
line(x1, y1, z1, x2, y2, z2)
Parameters
x1 float: x-coordinate of the first point
y1 float: y-coordinate of the first point
x2 float: x-coordinate of the second point
y2 float: y-coordinate of the second point
z1 float: z-coordinate of the first point
z2 float: z-coordinate of the second point

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

arrow
arrow
    全站熱搜

    fishark 發表在 痞客邦 留言(0) 人氣()