第一个问题在这里。我找到了这个视频: https://youtu.be/V2wDl_takes
有人知道他怎么做的吗?谢谢。
到目前为止的代码:
import processing.video.*;
//import camera3D.*;
//import camera3D.generators.*;
import camera3D.generators.util.*;
float x;
float y;
Capture cam;
int switcher = 0;
PFont font;
String message = "";
PImage words1, words2, words3, words4, words5, words6, words7;
void setup(){
size(640, 480);
font = createFont("Arial",20,true);
//size(1920,1200);
stroke(0);
words1 = loadImage("words1.PNG");
words2 = loadImage("words2.PNG");
words3 = loadImage("words3.PNG");
words4 = loadImage("words4.PNG");
words5 = loadImage("words5.PNG");
words6 = loadImage("words6.PNG");
words7 = loadImage("words7.PNG");
cam = new Capture(this, 640, 480);
cam.start();
}
void draw(){
loadPixels();
filter(GRAY);
text("You are loved",0,0);
textAlign(CENTER);
textFont(font);
//translate(width/2,height/2);
float newx = constrain(x + random(-20, 20), 0, width);
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);
// Pick the color from the video, reversing x
color c =pixels[(width-1-midx) + midy*width];
// Draw a line from (x,y) to (newx,newy)
stroke(c);
strokeWeight(4);
line(x, y, newx, newy);
// Save (newx,newy) in (x,y)
x = newx;
y = newy;
if (cam.available()){
cam.read();
int skip = 20;
for (int x = 0; x < words1.width; x+=skip) {
for (int y = 0; y < words1.height; y+=skip) {
int index = x + y * words1.width;
float b = brightness(words1.pixels[index]);
float z = map(b, 0, 255, 250, -250);
fill(255-b);
pushMatrix();
popMatrix();
}
}
//String[] words = { "apple", "bear", "cat", "dog" };
//int index = int(random(words.length)); // Same as int(random(4))
//println(words[index]); // Prints one of the four words
if(switcher==0){
image(cam,0,0);
}
else if(switcher == 1){
scale(-1,1);
image(cam,-width,0);
}
else if(switcher == 2){
scale(-1,-1);
image(cam,-width,-height);
}
else{
println("Switcher = 0 again");
switcher = 0;
}
}
}```