-
Notifications
You must be signed in to change notification settings - Fork 0
/
sunsethills.js
73 lines (60 loc) · 1.75 KB
/
sunsethills.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function firstRectangleColor(){
document.getElementById("b0").style.background = "yellow";
}
var buildings = ["b0", "b1", "b2", "b3", "b4"];
firstRectangleColor();
function build_size(idval, size){
let target_build = idval.slice(-2,idval.length);
console.log(target_build);
console.log(document.getElementById(target_build).style.height);
el = document.getElementById(target_build);
const myAnimation = anime({
targets: el,
easing: 'linear',
height: {
duration: 300,
value: size * 50 + "px"
}
});
let arr = getBuildingHeights(buildings);
console.log(arr);
setBuildingColor(arr);
}
function getBuildingHeights(buildings){
let arr = [];
buildings.forEach(element => {
arr.push(parseInt(document.getElementById("h_"+element).value))
});
return arr;
}
function setBuildingColor(arr){
let max_index=0;
let max_height=0;
for(i=0;i<arr.length; i++){
if (arr[i] > max_height){
max_height = arr[i];
max_index = i;
console.log("b"+ i);
var el = document.getElementById("b"+ i);
animateColor(el, 'rgb(255,255,0)');
console.log(i);
}
else{
var el = document.getElementById("b"+ i);
animateColor(el, 'rgb(128,128,128)');
}
console.log('max height is: ');
console.log(max_height);
}
}
function animateColor(target, color){
var changecolor = anime({
targets: target,
background: color,
easing: 'easeInQuad'
});
}
function getFirstRectangleColor(){
var color = document.getElementById("b0").style.background;
return color;
}