我正在使用处理2.1。 知道为什么我的简单草图在我的(强大的)机器上运行缓慢吗?
我只是在网格中绘制一些四边形,当我按下鼠标时我试图为它们设置动画(通过Ani库),但动画很邋and和超低......任何提示?
import de.looksgood.ani.*;
import de.looksgood.ani.easing.*;
int quadSize = 30;
int spacing = 10;
int numRows = 11;
int numColumns = 22;
float angleRotationIncrease = 3;
void setup () {
size (900, 600, P3D);
background (0);
fill (255);
stroke (255);
Ani.init(this);
frameRate (60);
}
void draw () {
text(frameRate,20,20);
// println (angleRotationIncrease);
background (0);
int posX = 0;
int posY = 0;
int angleRotation = 0;
float scaleFactor = 1;
float scaleFactorIncrease = -0.045;
for (int i=0; i<numRows; i++) {
for (int j=0; j<numColumns; j++) {
pushMatrix();
translate (posX + quadSize/2, posY + quadSize/2);
// println (radians(angleRotation));
rotate(radians(angleRotation));
if (scaleFactor > 0) {
rect (-quadSize/2 * scaleFactor, -quadSize/2* scaleFactor, quadSize* scaleFactor, quadSize* scaleFactor);
}
popMatrix ();
posX += (quadSize + spacing);
angleRotation += angleRotationIncrease;
scaleFactor += scaleFactorIncrease;
}
// for each new line, reset or change params
scaleFactorIncrease -= 0.002;
scaleFactor = 1;
angleRotation = 0;
posX = 0;
posY += (quadSize + spacing);
}
}
void mousePressed() {
Ani.to(this, 20, "angleRotationIncrease", -3);
}
答案 0 :(得分:1)
解决。这是一个铸造问题。 Anglerotation是一个int,所以当减去我通过Ani动画的值时,它会被舍入
答案 1 :(得分:0)
因为您在很长一段时间内制作了低范围的值
Ani.to(this, 20, "angleRotationIncrease", -3);
你的范围是[3,-3],时间是20秒。只是尝试减少时间并增加范围,您将在强大的机器上看到更流畅的动画:)这样:
Ani.to(this, 2, "angleRotationIncrease", -30);
但是在动画结束时,Ani
库默认应该指定什么样的速度,以便更多信息阅读文档here