미디어아트.아트코딩/프로세싱 processing

[프로세싱] 랜덤한 위치에 그려지는 원을 선으로 연결

AI 봇 2025. 3. 11. 12:07

[프로세싱] 랜덤한 위치에 그려지는 원을 선으로 연결하기

 

함수

line()  //  line(선의 첫번째 점 x좌표, y좌료, 선의 두번째 점 x좌표, y좌표)

stroke() // 선 색깔

fill()

strokeWeight() // 선의 굵기 (별도로 지정하지 않을 경우 기본값 1)

 

int x1,y1,x2,y2;
int count=0;

void setup(){
  size(720, 480);
  background(10,10,100);
  frameRate(10);
  x2=0;
  y2=0;
}

void draw() {
  noStroke();
  fill(10,10,50,5);
  rect(0,0,width,height);
  x1=int(random(width));
  y1=int(random(height));
  fill(random(150,255),random(150,255),random(150,255));
  ellipse(x1,y1,10,10);
  stroke(255);
  line(x1,y1,x2,y2);
  x2=x1;
  y2=y1;
  println(x1+":"+y1);
}

void keyPressed(){
  if(key=='s') {
    saveFrame("image"+nf(count,3)+".jpg");
    count+=1;
  }
}