-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfader.cpp
More file actions
55 lines (53 loc) · 1.47 KB
/
fader.cpp
File metadata and controls
55 lines (53 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "fader.h"
//-------------------------------------------------------------------
int Fader::Atualiza(void)
{
if (atual <= tempo1 + tempo2 + tempo3) atual++;
if (tipo == ESCURO_CLARO_ESCURO)
{
if (atual < tempo1)
{
if (tempo1 == 0) return max;
else return (atual / tempo1);
}
else if (atual >= tempo1 && atual - tempo1 < tempo2)
{
return max;
}
else if (atual >= tempo1 + tempo2 && atual - tempo1 - tempo2 < tempo3)
{
if (tempo3 == 0) return min;
else return min + ((max - min) - (max - min) * ((atual - tempo1 - tempo2) / tempo3));
}
return min;
}
else if (tipo == CLARO_ESCURO_CLARO)
{
if (atual < tempo1)
{
if (tempo1 == 0) return min;
else return min + ((max - min) * (tempo1 - atual) / tempo1);
}
else if (atual >= tempo1 && atual - tempo1 < tempo2)
{
return min;
}
else if (atual >= tempo1 + tempo2 && atual - tempo1 - tempo2 < tempo3)
{
if (tempo3 == 0) return max;
else return (min + ((max - min)* (atual - tempo1 - tempo2) / tempo3));
}
return max;
}
}
//------------------------------------------------------------------
Fader::Fader(int tipoAux, int tempo1Aux, int tempo2Aux, int tempo3Aux, int maxAux, int minAux)
{
atual = 0;
tipo = tipoAux;
tempo1 = tempo1Aux;
tempo2 = tempo2Aux;
tempo3 = tempo3Aux;
max = maxAux;
min = minAux;
}