-
Notifications
You must be signed in to change notification settings - Fork 1
/
Visualizator.js
51 lines (34 loc) · 1.19 KB
/
Visualizator.js
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
class Visualizator{
constructor(){
this.canvas = null;
this.canvas2 = null;
this.context = null;
this.context2 = null;
}
printPersonCanvas(){
context.clearRect(0,0,canvas.width,canvas.height);
for(var i=0; i < sim.sizepopulation; i++){
sim.population[i].print(context);
sim.population[i].mover();
//if(changeday)
sim.population[i].addDay();
}
}
printDataDOM(){
nrecovered.innerHTML = sim.qtdrecovered * 100/ sim.sizepopulation + " %"
nsick.innerHTML = sim.qtdinfecteds * 100/ sim.sizepopulation + " %"
nhealthy.innerHTML = (sim.sizepopulation - (sim.qtdinfecteds + sim.qtdrecovered)) * 100/ sim.sizepopulation + " %" ;
}
printDataCanvas(){
context2.fillStyle = "#79a6d2";
context2.fillRect(0,0, canvas.width,canvas.height);
for(var i = 0; i < sim.arrayQtdinfecteds.length; i++){
context2.fillStyle = "#cc2900";
context2.fillRect( i/4, 100 - ( sim.arrayQtdinfecteds[i] * 100/ sim.sizepopulation), 1 ,
(sim.arrayQtdinfecteds[i] * 100/ sim.sizepopulation) );
context2.fillStyle = "#ff66ff";
context2.fillRect( i/4, 0, 1 , (sim.arrayQtdrecovered[i] * 100/ sim.sizepopulation) );
//arrayQtdrecovered[i];
}
}
}