下面是我的代码,在运行时它显示了我想要的多个框,但是当我尝试导出时,它只在该帧位置显示一个框。我尝试在特定帧生成输出,但它有同样的问题
import processing.pdf.*;
int ofs = 500;
boolean record;
void setup() {
size(1900, 1080, P3D);
}
void draw() {
if (record) {
beginRaw(PDF, "box.pdf");
}
background(255);
translate(width/2, height/2, -800);
rotateZ(0.3);
rotateY(frameCount/500.0);
float x = sin(radians(frameCount*0.1));
for ( int xo = -ofs; xo<=ofs; xo += 100) {
for ( int yo = -ofs; yo<=ofs; yo += 100) {
pushMatrix();
translate ( xo, yo, 0);
box(200*x);
fill(155,150,90);
strokeWeight(3*x);
popMatrix();
if (record) {
endRaw();
record = false;
}
}
}
}
void keyPressed() {
if (key == 'r') {
record = true;
}
}
很近! :)
也许格式可能会让发现问题变得更加困难。
你正在呼唤endRaw();
(包含 pdf 记录)嵌套在for
loops.
这意味着它只拿起第一个盒子,因为record
被设定为false
所以其他框被忽略。
我建议使用编辑 > 自动格式(CMD + T / Ctrl + T)。
只需移动if(record)
嵌套之后for
loops:
import processing.pdf.*;
int ofs = 500;
boolean record;
void setup() {
size(1400, 580, P3D);
}
void draw() {
if (record) {
beginRaw(PDF, "box.pdf");
}
background(255);
translate(width/2, height/2, -800);
rotateZ(0.3);
rotateY(frameCount/500.0);
float x = sin(radians(frameCount*0.1));
for ( int xo = -ofs; xo<=ofs; xo += 100) {
for ( int yo = -ofs; yo<=ofs; yo += 100) {
pushMatrix();
translate ( xo, yo, 0);
box(200*x);
fill(155, 150, 90);
strokeWeight(3*x);
popMatrix();
}
}
// finish recording to PDF only after everything was drawn
if (record) {
endRaw();
record = false;
}
}
void keyPressed() {
if (key == 'r') {
record = true;
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)