⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 radialpocky.pde

📁 This is processing for java examples.
💻 PDE
字号:
/**  * Radial Pocky * by Ben Fry.  *  * Unwrap each frame of live video into a single line of pixels along a circle */     import processing.video.*;Capture video;int videoCount;int currentAngle;int pixelCount;int angleCount = 200;  // how many divisionsint radii[];int angles[];void setup() {  // size must be set to video.width*video.height*2 in both directions  size(960, 540);   // Uses the default video input, see the reference if this causes an error  video = new Capture(this, 24, 16);  videoCount = video.width * video.height;  pixelCount = width*height;  int centerX = width / 2;  int centerY = height / 2;  radii = new int[pixelCount];  angles = new int[pixelCount];  int offset = 0;  for (int y = 0; y < height; y++) {    for (int x = 0; x < width; x++) {      int dx = centerX - x;      int dy = centerY - y;      float angle = atan2(dy, dx);      if (angle < 0) angle += TWO_PI;      angles[offset] = (int) (angleCount * (angle / TWO_PI));      int radius = (int) mag(dx, dy);      if (radius >= videoCount) {        radius = -1;        angles[offset] = -1;      }      radii[offset] = radius;            offset++;    }  }  background(0);}void draw() {  if (video.available()) {    video.read();    video.loadPixels();      loadPixels();    for (int i = 0; i < pixelCount; i++) {      if (angles[i] == currentAngle) {        pixels[i] = video.pixels[radii[i]];      }    }    updatePixels();        currentAngle++;    if (currentAngle == angleCount) currentAngle = 0;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -