0
我正在使用程序處理,並且遇到了困難。 當試圖使圖像的色彩,使之透明一定的時間後,也不會做到這一點,我有什麼至今:使圖像在滿足特定條件後變爲零oppacity
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 oppacity到0,但是,它只是坐在那裏,事後沒有做任何幫助,將不勝感激。