Skip to content

Commit fedcdd6

Browse files
Added bar glow
1 parent 84bc23e commit fedcdd6

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

LivelyProperties.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@
5353
"type": "slider",
5454
"value": 50
5555
},
56+
"barGlow": {
57+
"max": 25,
58+
"min": 0,
59+
"tick": 25,
60+
"step": 1,
61+
"text": "Bar glow",
62+
"type": "slider",
63+
"value": 10
64+
},
5665
"barWidth": {
5766
"max": 25,
5867
"min": 1,

main.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ let endHue = 180
66
let saturation = 50
77
let lightness = 50
88
let compensation = 50
9+
let glow = 10
910

1011
let debug = document.getElementById("debug")
1112
let middle = document.getElementById("middle")
@@ -36,6 +37,7 @@ function livelyAudioListener(audioArray) {
3637
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height)
3738
ctx.lineWidth = barWidth
3839
ctx.lineCap = "round"
40+
ctx.shadowBlur = glow
3941

4042
if (audio.length > 2) {
4143
// Draw each bar
@@ -48,9 +50,11 @@ function livelyAudioListener(audioArray) {
4850
ctx.rotate(2 * Math.PI * ratio)
4951

5052
// Color from given hue, saturation, lightness
51-
ctx.strokeStyle = `hsl(${
53+
let color = `hsl(${
5254
((endHue - startHue) * halfRatio + startHue) % 360
5355
}, ${saturation}%, ${lightness}%)`
56+
ctx.strokeStyle = color
57+
ctx.shadowColor = color
5458

5559
// Move to approparite height
5660
ctx.moveTo(0, innerRadius)
@@ -107,6 +111,9 @@ function livelyPropertyListener(name, val) {
107111
case "barCompensation":
108112
compensation = val
109113
break
114+
case "barGlow":
115+
glow = val
116+
break
110117

111118
default:
112119
console.error(`Unknown customization option: ${name}`)

0 commit comments

Comments
 (0)