对于处理,我仍然是一个相对较新的人。我们正在考虑在一个小型展览中循环展示我们的加工工作。有没有办法在循环中播放多个PDE?我知道我可以导出为帧,然后将它们组装成一个更长的可循环Quicktime文件,但我想知道是否有任何方法可以播放和循环文件本身?
另外,对于交互式PDE,呈现它们的最佳方式是什么?我们正在考虑让几台运行PDE的计算机进行处理,但如果让一个文件运行20分钟,然后打开另一个文件20分钟,那将是很好的。
提前感谢!
发布于 2017-03-09 06:27:41
您应该能够组合一个使用processing-java command line executable的外壳/批处理脚本。
您应该能够通过Tools > Install "processing-java"进行设置

如果您不适应bash/批处理脚本,您甚至可以编写一个启动处理草图的处理草图

下面是使用selectFolder()和exec()的粗略介绍
final int SKETCH_RUN_TIME = 10000;//10 seconds for each sketch, feel free to change
ArrayList<File> sketches = new ArrayList<File>();
int sketchIndex = 0;
void setup(){
selectFolder("Select a folder containing Processing sketches:", "folderSelected");
}
void draw(){
}
void nextSketch(){
//run sketch
String sketchPath = sketches.get(sketchIndex).getAbsolutePath();
println("launching",sketchPath);
Process sketch = exec("/usr/local/bin/processing-java",
"--sketch="+sketchPath,
"--present");
//increment sketch index for next time around (checking the index is still valid, otherwise go back to 0)
sketchIndex++;
if(sketchIndex >= sketches.size()){
sketchIndex = 0;
}
//delay is deprecated so you shouldn't use this a lot, but as a proof concept this will do
delay(SKETCH_RUN_TIME);
nextSketch();
}
void folderSelected(File selection) {
if (selection == null) {
println("No folder ? Ok, maybe another time. Bye! :)");
exit();
} else {
File[] files = selection.listFiles();
//filter just Processing sketches
for(int i = 0; i < files.length; i++){
if(files[i].isDirectory()){
String folderName = files[i].getName();
File[] sketchFiles = files[i].listFiles();
boolean isValidSketch = false;
//search for a .pde file with the same folder name to check if it's a valid sketch
for(File f : sketchFiles){
if(f.getName().equals(folderName+".pde")){
isValidSketch = true;
break;
}
}
if(isValidSketch) {
sketches.add(files[i]);
}else{
System.out.println(files[i]+" is not a valid Processing sketch");
}
}
}
println("sketches found:",sketches);
nextSketch();
}
}代码是注释的,所以希望它应该易于阅读和遵循。系统将提示您选择包含要运行的草图的文件夹。
注意1:我已经在我的机器上使用了processing-java路径(/usr/local/bin/processing-java)。如果你在Windows上,这可能会有所不同,你需要改变这一点。
注意2: processing-java命令会启动另一个Process,这使得在运行下一个草图之前关闭上一个草图变得很棘手。作为一种变通方法,您可以在所需的时间量之后对每个草图调用exit()。
注意3:代码不会递归地遍历包含草图的选定文件夹,因此只会执行第一级草图,任何更深层次的草图都应该被忽略。
https://stackoverflow.com/questions/42680407
复制相似问题