我正在使用程序处理并偶然发现了一个困难。当试图在一定时间后使图像着色以使其透明时,它不会这样做,我到目前为止:
import ddf.minim.*;
Minim minim;
AudioInput in;
PImage img;
int a = 125;//geluidswaarde
int fade = 0;//beginfade grote fade is zwarter
int stmin = 2; //fadestapje donkerder
int stplus = 10; //fadestapje lichter
float gw = 0.04;//gevoeligheid kleiner = gevoeliger
int trmin = 10; // transparanter
int trplus = 20; // voller
int A = 0;
void setup() {
img = loadImage("leegte.jpg");
size(1000, 1000);
frameRate(10); // Maximum 30 frames/beelden per seconde (speel hier gerust even mee)
image(img, 0, 0);
minim = new Minim(this);
// get a line in from Minim, default bit depth is 16
in = minim.getLineIn(Minim.STEREO, 640);
}
void draw() {
image(img, 0, 0);
fill(255);
rect(0, 0, 1000, 1000);
if (abs(in.left.get(a))> (gw)) {
fade = fade-stplus;
}
else {
fade = fade+stmin;
}
fade = constrain(fade, 0, 300);
fill(0, fade);
rect(0, 0, 1000, 1000);
while (fade>=300)
{
--A;
tint(0, A);
}
}
void stop()
{
// always close Minim audio classes when you are done with them
in.close();
minim.stop();
super.stop();
}
问题在于
while (fade>=300)
{
--A;
tint(0, A);
}
部分,在图像达到淡入淡出(0,300)后,我希望它开始着色,因此它从 255 不透明度变为 0,但是,它只是坐在那里,之后什么也不做,任何帮助将不胜感激。