forked from KleeGroup-BaseCamp/appviz-map
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
42 lines (39 loc) · 1.22 KB
/
utils.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
const handleHover = (element) => {
if (prevHoveredElement) {
prevHoveredElement.style.fill = COLORS[prevHoveredElement.layer.level];
}
if (element) {
document.querySelector("main").style.cursor = "pointer";
element.style.fill = HOVER_COLOR;
} else {
document.querySelector("main").style.cursor = "default";
}
prevHoveredElement = element;
};
const applyStyle = (style) => {
if (style.stroke) stroke(style.stroke);
if (style.strokeWeight) strokeWeight(style.strokeWeight);
if (style.fill) fill(...style.fill);
};
//Temporary function for testing purposes only.
const initLayers = () => {
let layer1 = new Layer(4, 6);
layer1.addElement(
new Rectangle({ column: 0, row: 2, numOfColumns: 2, numOfRows: 2 })
);
layer1.addElement(
new Hexagone({ column: 2, row: 1, numOfColumns: 2, numOfRows: 1 })
);
let layer2 = new Layer(4, 6);
layer2.addElement(
new Rectangle({ column: 0, row: 2, numOfColumns: 1, numOfRows: 1 })
);
layer2.addElement(
new Rectangle({ column: 1, row: 2, numOfColumns: 1, numOfRows: 1 })
);
let layer3 = new Layer(4, 6);
layer3.addElement(
new Hexagone({ column: 0, row: 2, numOfColumns: 1, numOfRows: 1 })
);
return [layer1, layer2, layer3];
};