ScribblePerson

scribble person
import processing.video.*;

// Two global variables
float x;
float y;
Capture video;

void setup() {
  size(320, 240);
  smooth();
  background(255);
  video=new Capture(this, 320, 240, 15);
  video.start();

  // Start x and y in the center
  x = width/2;
  y = height/2;
}
void draw() {
  if (video.available()) {
    video.read();
  }
  video.loadPixels();

  // Pick a new x and y
  float newx = constrain(x + random(-20, 20), 0, width-1);
  float newy = constrain(y + random(-20, 20), 0, height-1);

  // Find the midpoint of the line
  int midx = int((newx + x) / 2);
  int midy = int((newy + y) / 2);
  int loc=(midy+1)*video.width-midx-1;
  color c=video.pixels[loc];
  
  // Draw a line from x,y to the newx,newy
  stroke(c);
  strokeWeight(4);
  line(x, y, newx, newy);
  // Save newx, newy in x,y
  x = newx;
  y = newy;
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容