Skip to content

Commit

Permalink
Add background image support
Browse files Browse the repository at this point in the history
  • Loading branch information
rogeraabbccdd committed Apr 3, 2020
1 parent d1aca0f commit 1491f95
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ SDVX Live2D Wallpaper for [Wallpaper Engine](https://store.steampowered.com/app/
- Download repo.
- Download `live2dcubismcore.min.js` from [here](https://www.live2d.com/download/cubism-sdk/download-web/), add put it in `assets/js/`.
- Get your SDVX Live2D models from somewhere, and put them in `assets/live2d/`.
- Download BGM from [here](https://www.youtube.com/watch?v=tBd_QlnYwNg), and put it in `assets/sound/sdvxv.mp3`.
- Get your SDVX `testbg2_fhd.wmv` from somewhere, convert it to webm format and put it in `assets/video/bg.webm`.
- Download BGM from [here](https://www.youtube.com/watch?v=tBd_QlnYwNg), and put it in `assets/sound/bgm.mp3`.
- Get your SDVX `testbg2_fhd.wmv` from somewhere, or any background video you want, convert it to webm format and put it in `assets/background/bg.webm`.
- Get your favorite SDVX wallpaper image, and put it in `assets/background/bg.jpg`.
- Import folder to Wallpaper Engine.

## Credits
- `bg2.webm` is taken from [Steam Workshop](https://steamcommunity.com/sharedfiles/filedetails/?id=1940540424)
- Default `bg.webm` is taken from [Steam Workshop](https://steamcommunity.com/sharedfiles/filedetails/?id=1940540424)
Binary file added assets/background/bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
5 changes: 5 additions & 0 deletions assets/css/sdvx.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ body {
width: 100vw;
position: fixed;
z-index: -1;
background-image: url(../background/bg.jpg);
background-attachment: fixed;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}

#bg-video {
Expand Down
21 changes: 14 additions & 7 deletions assets/js/wallpaper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ let modelName = "grace_ver5"
let model = new Live2dModel()
model.loadModel(modelName);
window.onresize = model.onResize()
const bgVideo = document.getElementById("bg-video")
const bg = document.getElementById('bg')
const bgm = document.getElementById('bgm')
window.wallpaperPropertyListener = {
applyUserProperties(properties) {
if (properties.modelName) {
Expand All @@ -24,16 +27,20 @@ window.wallpaperPropertyListener = {
model.onResize();

// other
if (properties.videoBright) {
document.getElementById("bg").style.filter = `brightness(${properties
.videoBright.value / 100})`;
if (properties.bgBright) {
bg.style.filter = `brightness(${properties
.bgBright.value / 100})`;
}
if (properties.video) {
document.getElementById("bg-video").src =
"./assets/video/" + properties.video.value + ".webm";
if (properties.bgType) {
if(properties.bgType.value === 'video') {
bgVideo.style.display = 'inline'
}
else {
bgVideo.style.display = 'none'
}
}
if (properties.volume) {
document.getElementById("bgm").volume = properties.volume.value / 100;
bgm.volume = properties.volume.value / 100;
}
}
};
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</head>
<body>
<div id="bg">
<video autoplay muted loop id="bg-video" src="./assets/video/bg.webm"></video>
<video autoplay muted loop id="bg-video" src="./assets/background/bg.webm"></video>
</div>
<audio src="./assets/sound/sdvxv.mp3" id="bgm" autoplay loop volume="0"></audio>
<audio src="./assets/sound/bgm.mp3" id="bgm" autoplay loop volume="0"></audio>
<div id="live2d"></div>
<!-- Fetch and XHR are not working when loading local live2d json file :() -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
Expand Down

0 comments on commit 1491f95

Please sign in to comment.