我正在做一个艺术课的处理项目,我的计划是制作一个音频可视化工具,其中圆圈将从音频文件的振幅中出现。我的主要问题是,我试图实现一种涟漪效果,在生成后,圆圈将扩展并向外扩散,但我所有的圆圈都保持不变。下面是我的绘图函数:
void draw(){
int n = 1000;
fft.forward(song.mix);
for (int i = 0; i <fft.specSize(); i++ ) {
z = fft.getBand(i) * 20;
if (n < 150){
stroke(colors [(int)random(0,9)]);
strokeWeight(random(50, 300)); //bigger strokes towards the middle
ellipse(x, y, z, z); //basic lines and shapes
z ++;
}
else{
stroke(colors [(int)random(0,9)]);
strokeWeight(random(10));
ellipse(x, y, z, z); //basic lines and shapes
z ++;
}
}
}我不确定我在哪里出错,因为我在递增z,所以据我所知,每个椭圆都应该扩展。
发布于 2021-04-17 05:08:49
您没有看到任何扩展,因为您只是在单个绘制调用中递增z,然后它被重置。但为了查看扩展,z必须在多个绘制周期中递增。您可以使用if语句而不是循环来完成此操作。请注意,draw不断被调用。
int i = -1;
void draw(){
int n = 1000;
fft.forward(song.mix);
if(++i < fft.specSize()) {
z = fft.getBand(i) * 20;
if (n < 150){
stroke(colors [(int)random(0,9)]);
strokeWeight(random(50, 300)); //bigger strokes towards the middle
ellipse(x, y, z, z); //basic lines and shapes
z ++;
}else{
stroke(colors [(int)random(0,9)]);
strokeWeight(random(10));
ellipse(x, y, z, z); //basic lines and shapes
z ++;
}
}
}我还没有测试过它,但这应该会在椭圆展开时重新绘制它们。
附注:如果你的椭圆的高度和宽度相等,你可以使用circle(x, y, z)。
https://stackoverflow.com/questions/67131759
复制相似问题