使用 saveFrame() 保存的最后一帧的文件名是什么 [英] What is the filename of last saved frame using saveFrame()
问题描述
在处理中,您可以使用 saveFrame('output-####.png')
保存帧.这将保存框架,将其命名为 output-0001.png
,并将其放置在草图文件夹中.文件名总是不同的,因为它遵循一个序列,用序列中的下一个数字替换####.
In Processing, you can save a frame using saveFrame('output-####.png')
. That will save the frame, name it output-0001.png
, and place it in the sketch folder. The filename is always different because it follows a sequence, replacing the #### with the next number in the sequence.
然而,saveFrame 返回 void.我希望它返回文件名的字符串,但它没有.
However, saveFrame returns void. I wish it returned the String of the filename, but it doesn't.
如何找出用 saveFrame(...)
推荐答案
你总是可以用一个函数包装它,告诉你此时的 frameCount:
You can always wrap that with a function to tell you the frameCount at that point:
void draw() {
println(saveFrameAndGetFileName("output-####.png"));
}
String saveFrameAndGetFileName(String fileName) {
saveFrame(fileName);
String [] parts = fileName.split("####"); //getting pedantic here...
return parts[0] + frameCount + parts[1];
}
或者更简单:
void draw() {
saveFrame("output-####.png");
println("output-" + frameCount + ".png");
}
固定为您提供实际文件名
Fixed to give you the actual filename
这篇关于使用 saveFrame() 保存的最后一帧的文件名是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!