Skip to content

Commit 66a3163

Browse files
Inner circle movement, moving bg stars & bg blur
Feature requests are from lively subreddit
1 parent 0d00360 commit 66a3163

File tree

5 files changed

+164
-9
lines changed

5 files changed

+164
-9
lines changed

LivelyProperties.json

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010
"filter": "*.jpg|*.jpeg|*.png|*.webp|*.gif",
1111
"folder": "images"
1212
},
13+
"bgBlur": {
14+
"max": 10,
15+
"min": 0,
16+
"tick": 25,
17+
"step": 1,
18+
"text": "Background image blur",
19+
"type": "slider",
20+
"value": 0
21+
},
1322
"useMiddleImage": {
1423
"type": "checkbox",
1524
"value": false,
@@ -48,11 +57,20 @@
4857
"max": 90,
4958
"min": 0,
5059
"tick": 25,
51-
"step": 5,
60+
"step": 1,
5261
"text": "Inner space",
5362
"type": "slider",
5463
"value": 50
5564
},
65+
"innerMovement": {
66+
"max": 100,
67+
"min": 0,
68+
"tick": 25,
69+
"step": 1,
70+
"text": "Inner circle movement",
71+
"type": "slider",
72+
"value": 25
73+
},
5674
"barGlow": {
5775
"max": 25,
5876
"min": 0,
@@ -119,5 +137,37 @@
119137
"text": "Color lightness",
120138
"type": "slider",
121139
"value": 50
140+
},
141+
"starsLabel": {
142+
"type": "label",
143+
"value": "Background stars:"
144+
},
145+
"showStars": {
146+
"type": "checkbox",
147+
"value": true,
148+
"text": "Show background stars"
149+
},
150+
"starColor": {
151+
"text": "Star color",
152+
"type": "color",
153+
"value": "#FFFFFF"
154+
},
155+
"starOpacity": {
156+
"max": 100,
157+
"min": 1,
158+
"tick": 25,
159+
"step": 1,
160+
"text": "Star opacity",
161+
"type": "slider",
162+
"value": 50
163+
},
164+
"starGlow": {
165+
"max": 25,
166+
"min": 0,
167+
"tick": 25,
168+
"step": 1,
169+
"text": "Star glow",
170+
"type": "slider",
171+
"value": 15
122172
}
123173
}

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,19 @@ https://user-images.githubusercontent.com/18127101/117224561-86d8d880-ae10-11eb-
2626
- [x] Customizable bar amplitude
2727
- [x] Glowing bars
2828
- [x] Customizable center logo image
29-
- [ ] Background image blur option
29+
- [x] Background effects (snow/stars/debris with glow, similar to Trap Nation)
30+
- [x] Moving inner ring (similar to NCS)
31+
- [x] Background image blur option
3032
- [ ] Different types of visualizers (eg. lines from bottom)
31-
- [ ] Background effects (snow/stars/debris with glow, similar to Trap Nation)
32-
- [ ] Moving inner ring (similar to NCS)
3333
- [ ] Change visualizer position
3434
- [ ] Camera shake/wobble for background and/or visualizer
3535
- [ ] Multi monitor background span
3636
- [ ] Smoother bar visualizer bars
3737

38-
## Problems
38+
## Troubleshooting
3939

4040
If the visualizer is not reacting to sound, try [this solution](https://help.wallpaperengine.io/en/audio/intermittent.html):
41+
4142
> USB / wireless headsets are prone to sound driver issues. For many devices, changing the audio sample rate in the Windows device settings to 44100 Hz permanently fixes the issue:
4243
> Right-click on the audio icon in the tray area in the lower right corner of Windows, select "Open Sound Settings". Click on "Device Properties" in the "Output" section of the window that opens up. Afterwards, click on "Additional device properties", then navigate to the "Advanced" tab. You can change the sampling rate in the menu shown there. The exact location is different on different versions of Windows. if you cannot find this option, search the web for guides on how to change the sampling rate of sound devices for your version of Windows.
4344
> Set the sampling rate to "24 bit, 44100 Hz"

index.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
<style>
1010
html,
1111
body,
12-
#canvas {
12+
#canvas,
13+
#starfield {
1314
margin: 0;
1415
padding: 0;
1516
height: 100%;
@@ -18,6 +19,11 @@
1819
user-select: none;
1920
}
2021

22+
#starfield {
23+
position: absolute;
24+
z-index: -10;
25+
}
26+
2127
body {
2228
background-position: center;
2329
background-repeat: no-repeat;
@@ -43,12 +49,15 @@
4349
</head>
4450

4551
<body>
52+
<canvas id="starfield"></canvas>
53+
4654
<img id="middle" />
4755
<canvas id="canvas"></canvas>
4856

4957
<pre id="debug"></pre>
5058

5159
<script src="main.js"></script>
60+
<script src="stars.js"></script>
5261
</body>
5362

5463
</html>

main.js

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ let saturation = 50
77
let lightness = 50
88
let compensation = 50
99
let glow = 10
10+
let innerMovement = 25
11+
12+
let showStars = true
13+
let starColor = "#FFFFFF"
14+
let starOpacity = 50
15+
let starGlow = 15
1016

1117
let debug = document.getElementById("debug")
1218
let middle = document.getElementById("middle")
@@ -25,6 +31,9 @@ ctx.globalCompositeOperation = "destination-over"
2531
// ctx.strokeStyle = grad
2632

2733
function livelyAudioListener(audioArray) {
34+
// Set overall level
35+
average = audioArray.reduce((acc, val) => acc + val) / audioArray.length
36+
star_speed = average * 32
2837
// Remove duplicate frequencies
2938
let audio = audioArray.filter((elem, idx, arr) => arr[idx - 1] !== elem)
3039
// Compensate for overamplified bass
@@ -47,6 +56,7 @@ function livelyAudioListener(audioArray) {
4756
ctx.beginPath()
4857
// Center origin
4958
ctx.translate(ctx.canvas.width / 2, ctx.canvas.height / 2)
59+
// Rotate each bar
5060
ctx.rotate(2 * Math.PI * ratio)
5161

5262
// Color from given hue, saturation, lightness
@@ -56,10 +66,11 @@ function livelyAudioListener(audioArray) {
5666
ctx.strokeStyle = color
5767
ctx.shadowColor = color
5868

69+
let innerOffset = average * maxLength * (innerMovement / 100)
5970
// Move to approparite height
60-
ctx.moveTo(0, innerRadius)
71+
ctx.moveTo(0, innerRadius + innerOffset)
6172
// Draw line outwards from origin
62-
ctx.lineTo(0, val * maxLength + innerRadius)
73+
ctx.lineTo(0, val * maxLength + innerRadius + innerOffset)
6374
// Apply stroke
6475
ctx.stroke()
6576
// Reset current transformation matrix to the identity matrix
@@ -87,6 +98,9 @@ function livelyPropertyListener(name, val) {
8798
case "bgImage":
8899
document.body.style.backgroundImage = `url(/${val.replace(/\\/g, "/")})`
89100
break
101+
case "bgBlur":
102+
document.body.style.backdropFilter = `blur(${Math.round(val)}px)`
103+
break
90104
case "useMiddleImage":
91105
middle.style.display = val ? "block" : "none"
92106
break
@@ -114,9 +128,24 @@ function livelyPropertyListener(name, val) {
114128
case "barGlow":
115129
glow = val
116130
break
131+
case "innerMovement":
132+
innerMovement = val
133+
break
134+
case "showStars":
135+
showStars = val
136+
break
137+
case "starColor":
138+
starColor = val
139+
break
140+
case "starOpacity":
141+
starOpacity = val
142+
break
143+
case "starGlow":
144+
starGlow = val
145+
break
117146

118147
default:
119-
console.error(`Unknown customization option: ${name}`)
148+
// console.error(`Unknown customization option: ${name}`)
120149
break
121150
}
122151
}

stars.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
let n = 256
2+
let w = document.documentElement.clientWidth
3+
let h = document.documentElement.clientHeight
4+
let x_mid = Math.round(w / 2)
5+
let y_mid = Math.round(h / 2)
6+
let z = (w + h) / 2
7+
let star_color_ratio = 1 / z
8+
let star_x_save, star_y_save
9+
let star_ratio = 256
10+
let star_speed = 4
11+
let stars = []
12+
13+
let context
14+
15+
function init() {
16+
for (let i = 0; i < n; i++) {
17+
stars.push({
18+
x: Math.random() * w * 2 - x_mid * 2,
19+
y: Math.random() * h * 2 - y_mid * 2,
20+
speed: Math.round(Math.random() * z),
21+
new_x: 0,
22+
new_y: 0,
23+
size: Math.round(Math.random() * 6 + 2),
24+
})
25+
}
26+
let starfield = document.getElementById("starfield")
27+
starfield.width = w
28+
starfield.height = h
29+
context = starfield.getContext("2d")
30+
context.lineCap = "round"
31+
// context.filter = "blur(1px)"
32+
}
33+
34+
function anim() {
35+
context.clearRect(0, 0, w, h)
36+
context.strokeStyle = starColor
37+
context.globalAlpha = starOpacity / 100
38+
context.shadowBlur = starGlow
39+
context.shadowColor = starColor
40+
41+
if (showStars && star_speed) {
42+
for (let star of stars) {
43+
star_x_save = star.new_x
44+
star_y_save = star.new_y
45+
star.speed -= star_speed
46+
if (star.speed < 0) {
47+
star.speed += z
48+
}
49+
star.new_x = x_mid + (star.x / star.speed) * star_ratio
50+
star.new_y = y_mid + (star.y / star.speed) * star_ratio
51+
if (star_x_save > 0 && star_x_save < w && star_y_save > 0 && star_y_save < h) {
52+
context.lineWidth = (1 - star_color_ratio * star.speed) * 2
53+
context.beginPath()
54+
context.lineWidth = star.size
55+
context.moveTo(star_x_save, star_y_save)
56+
context.lineTo(star_x_save, star_y_save)
57+
// context.lineTo(star.new_x, star.new_y)
58+
context.stroke()
59+
}
60+
}
61+
}
62+
}
63+
64+
init()
65+
setInterval(anim, 16)
66+
// anim()

0 commit comments

Comments
 (0)