Performance 知道为什么这个处理草图运行得这么慢吗?

Performance 知道为什么这个处理草图运行得这么慢吗?,performance,processing,Performance,Processing,我使用的是processing 2.1。 你知道为什么我的简单草图在我的(功能强大的)机器上运行缓慢吗 我只是在网格中绘制一些四边形,当按下鼠标时,我试图设置它们的动画(通过Ani库),但动画是草率的和超低的…有什么提示吗 import de.looksgood.ani.*; import de.looksgood.ani.easing.*; int quadSize = 30; int spacing = 10; int numRows = 11; int numColumns = 22;

我使用的是processing 2.1。 你知道为什么我的简单草图在我的(功能强大的)机器上运行缓慢吗

我只是在网格中绘制一些四边形,当按下鼠标时,我试图设置它们的动画(通过Ani库),但动画是草率的和超低的…有什么提示吗

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);
}
import de.looksgood.ani.*;
导入de.looksgood.ani.easing.*;
int quadSize=30;
整数间距=10;
int numRows=11;
int numColumns=22;
浮动角度旋转增量=3;
无效设置(){
尺寸(900600,P3D);
背景(0);
填充(255);
中风(255);
Ani.init(本);
帧率(60);
}
无效提款(){
文本(帧率,20,20);
//println(角度旋转增量);
背景(0);
int posX=0;
int-posY=0;
int角度旋转=0;
float scaleFactor=1;
浮动比例系数增加=-0.045;

对于(int i=0;i,因为在很长的一段时间内设置了低范围值的动画

Ani.to(this, 20, "angleRotationIncrease", -3);
您的范围是[3,-3],时间是20秒。只需减少时间并增加范围,您将在您强大的机器上看到更流畅的动画:)如下所示:

Ani.to(this, 2, "angleRotationIncrease", -30);

但在动画结束时,某种程度上减慢了Ani库默认指定的速度,因此有关更多信息,请阅读文档。这是一个铸造问题。角度旋转是一个整数,因此在减去我通过Ani制作动画的值时,它会四舍五入,但它没有解释动画持续的原因如果取消对println的注释(角度旋转增加),您将看到动画应该有更多的步骤,而实际上您可以看到的步骤更多,但动画更改值
float angleRotationIncrease
,该值添加到
int angleRotation
,因此结果是您只会偶尔更改角度一次。尝试将角度更改为
float
,然后您将看到更多的动画步骤。交叉发帖,看看我自己刚刚发布的答案:)是的,看起来我们是在同一时间发布的:)如果你想用正确的答案更改你的答案,我会将你的答案标记为已接受-谢谢你的帮助