Skip to content

Commit 56bf235

Browse files
author
Silke Reich
committed
Set colors for mdivs dynamically and repeat after 10 mdivs
1 parent 6d819ce commit 56bf235

File tree

1 file changed

+32
-122
lines changed

1 file changed

+32
-122
lines changed

src/components/OsdComponent.vue

+32-122
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ export default {
1414
name: 'OsdComponent',
1515
components: {
1616
17+
},
18+
data() {
19+
return {
20+
colors: [
21+
'rgba(255, 87, 51, 0.2)', 'rgba(51, 255, 87, 0.2)', 'rgba(51, 87, 255, 0.2)', 'rgba(255, 51, 161, 0.2)', 'rgba(161, 51, 255, 0.2)',
22+
'rgba(51, 255, 245, 0.2)', 'rgba(255, 140, 51, 0.2)', 'rgba(140, 255, 51, 0.2)', 'rgba(51, 140, 255, 0.2)', 'rgba(255, 51, 140, 0.2)'
23+
],
24+
colorIndex: 0
25+
}
1726
},
1827
computed: {
1928
imageArray: function () {
@@ -27,7 +36,11 @@ export default {
2736
}
2837
},
2938
methods: {
30-
39+
getNextColor() {
40+
const color = this.colors[this.colorIndex];
41+
this.colorIndex = (this.colorIndex + 1) % this.colors.length;
42+
return color;
43+
},
3144
renderZones: function () {
3245
this.viewer.clearOverlays()
3346
const annots = this.$store.getters.zonesOnCurrentPage
@@ -98,7 +111,24 @@ export default {
98111
e.stopPropagation()
99112
})
100113
101-
114+
// Set the background color dynamically
115+
const color = this.getNextColor();
116+
const borderColor = color.replace(/[\d\.]+\)$/g, '0.5)')
117+
118+
// Set colors
119+
overlay.style.backgroundColor = color
120+
overlay.style.outline = `1px solid ${borderColor}`
121+
122+
// Set colors for :hover
123+
overlay.onmouseenter = () => {
124+
overlay.style.backgroundColor = color.replace(/[\d\.]+\)$/g, '0.1)')
125+
overlay.style.outline = borderColor.replace(/[\d\.]+\)$/g, '0.4)')
126+
}
127+
// Reset colors after :hover
128+
overlay.onmouseleave = () => {
129+
overlay.style.backgroundColor = color
130+
overlay.style.outline = borderColor
131+
}
102132
103133
this.viewer.addOverlay({
104134
element: overlay,
@@ -298,126 +328,6 @@ $thickLineColor: #cccccc66; // #ffffff99;
298328
background-color: rgba(255,255,255,.1);
299329
z-index: 10;
300330
301-
&.mov_0 {
302-
background-color: transparentize($mdiv0ZoneColor, .8);
303-
outline: 1px solid transparentize($mdiv0ZoneColor, .4);
304-
305-
&:hover {
306-
background-color: transparentize($mdiv0ZoneColor, .6);
307-
outline: 1px solid transparentize($mdiv0ZoneColor, .4);
308-
}
309-
}
310-
311-
&.mov_1 {
312-
background-color: transparentize($mdiv1ZoneColor, .8);
313-
outline: 1px solid transparentize($mdiv1ZoneColor, .4);
314-
315-
&:hover {
316-
background-color: transparentize($mdiv1ZoneColor, .6);
317-
outline: 1px solid transparentize($mdiv1ZoneColor, .4);
318-
}
319-
}
320-
321-
&.mov_2 {
322-
background-color: transparentize($mdiv2ZoneColor, .8);
323-
outline: 1px solid transparentize($mdiv2ZoneColor, .4);
324-
325-
&:hover {
326-
background-color: transparentize($mdiv2ZoneColor, .6);
327-
outline: 1px solid transparentize($mdiv2ZoneColor, .4);
328-
}
329-
}
330-
331-
&.mov_3 {
332-
background-color: transparentize($mdiv3ZoneColor, .8);
333-
outline: 1px solid transparentize($mdiv3ZoneColor, .4);
334-
335-
&:hover {
336-
background-color: transparentize($mdiv3ZoneColor, .6);
337-
outline: 1px solid transparentize($mdiv3ZoneColor, .4);
338-
}
339-
}
340-
341-
&.mov_4 {
342-
background-color: transparentize($mdiv4ZoneColor, .8);
343-
outline: 1px solid transparentize($mdiv4ZoneColor, .4);
344-
345-
&:hover {
346-
background-color: transparentize($mdiv4ZoneColor, .6);
347-
outline: 1px solid transparentize($mdiv4ZoneColor, .4);
348-
}
349-
}
350-
351-
&.mov_5 {
352-
background-color: transparentize($mdiv5ZoneColor, .8);
353-
outline: 1px solid transparentize($mdiv5ZoneColor, .4);
354-
355-
&:hover {
356-
background-color: transparentize($mdiv5ZoneColor, .6);
357-
outline: 1px solid transparentize($mdiv5ZoneColor, .4);
358-
}
359-
}
360-
361-
&.mov_6 {
362-
background-color: transparentize($mdiv6ZoneColor, .8);
363-
outline: 1px solid transparentize($mdiv6ZoneColor, .4);
364-
365-
&:hover {
366-
background-color: transparentize($mdiv6ZoneColor, .6);
367-
outline: 1px solid transparentize($mdiv6ZoneColor, .4);
368-
}
369-
}
370-
371-
&.mov_7 {
372-
background-color: transparentize($mdiv7ZoneColor, .8);
373-
outline: 1px solid transparentize($mdiv7ZoneColor, .4);
374-
375-
&:hover {
376-
background-color: transparentize($mdiv7ZoneColor, .6);
377-
outline: 1px solid transparentize($mdiv7ZoneColor, .4);
378-
}
379-
}
380-
381-
&.mov_8 {
382-
background-color: transparentize($mdiv8ZoneColor, .8);
383-
outline: 1px solid transparentize($mdiv8ZoneColor, .4);
384-
385-
&:hover {
386-
background-color: transparentize($mdiv8ZoneColor, .6);
387-
outline: 1px solid transparentize($mdiv8ZoneColor, .4);
388-
}
389-
}
390-
391-
&.mov_9 {
392-
background-color: transparentize($mdiv9ZoneColor, .8);
393-
outline: 1px solid transparentize($mdiv9ZoneColor, .4);
394-
395-
&:hover {
396-
background-color: transparentize($mdiv9ZoneColor, .6);
397-
outline: 1px solid transparentize($mdiv9ZoneColor, .4);
398-
}
399-
}
400-
401-
&.mov_10 {
402-
background-color: transparentize($mdiv10ZoneColor, .8);
403-
outline: 1px solid transparentize($mdiv10ZoneColor, .4);
404-
405-
&:hover {
406-
background-color: transparentize($mdiv10ZoneColor, .6);
407-
outline: 1px solid transparentize($mdiv10ZoneColor, .4);
408-
}
409-
}
410-
411-
&.mov_11 {
412-
background-color: transparentize($mdiv11ZoneColor, .8);
413-
outline: 1px solid transparentize($mdiv11ZoneColor, .4);
414-
415-
&:hover {
416-
background-color: transparentize($mdiv11ZoneColor, .6);
417-
outline: 1px solid transparentize($mdiv11ZoneColor, .4);
418-
}
419-
}
420-
421331
.zoneLabel {
422332
text-align: center;
423333
position: absolute;

0 commit comments

Comments
 (0)