-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
178 lines (173 loc) · 7.09 KB
/
index.html
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="max-age=7200" />
<meta http-equiv="x-dns-prefetch-control" content="on">
<meta name="baidu-site-verification" content="1NA2Ma9K9x" />
<meta name="keywords" content="梅子丹" />
<meta name="description" content="梅子丹" />
<link rel="dns-prefetch" href="//veveue.github.io/">
<title>in time</title>
<style>
html,body{ background: url(./img/0.jpg) no-repeat; background-size: cover; padding: 0; margin: 0;height: 100%;width: 100%;-webkit-user-select: none;-moz-user-select: none;-o-user-select: none;user-select: none;}
a{text-decoration: none;color: #fff;}
#canvas{ position: fixed; left: -5%; bottom: -1%; transform: scale(0.7);}
.title{ text-align: center;height: 100%;display: flex;}
.title h1{ margin: 0 auto; align-self: center;font-size: 50px;cursor: pointer;opacity: 0.6; font-family: Comic Sans MS; -moz-text-shadow: 5px 5px 5px #f3d0ab; -webkit-text-shadow: 5px 5px 5px #f3d0ab; text-shadow: 5px 5px 5px #f3d0ab; line-height: 69px; height: 69px;}
.title h1:hover{ opacity: 1;text-shadow: none;-moz-text-shadow: none;-webkit-text-shadow: none;}
.title h1:active{ color: #9BC894;}
.svg-wrapper{ margin: 0 auto; position: relative; width: 250px; height: 66px; display: inline-block; border-radius: 3px; align-self: center;}
.svg-wrapper:hover #shape{ stroke-dasharray: 85 0; stroke-width: 6px; stroke-dashoffset: 0; stroke: #000;}
#text{ margin-top: -72px; text-align: center;}
#shape{ stroke-width: 6px; fill: transparent; stroke: #009FFD; stroke-dasharray: 85 400; stroke-dashoffset: -339; transition: 1s all ease;}
.before{ position: fixed; font-family: fantasy; bottom: 1%; right: 220px;}
#live2dcanvas{ position: fixed; bottom: 0; right: 1rem; opacity: 1; z-index: 999; pointer-events: none;}
@media screen and (max-width: 500px){ .title h1{ font-family: Helvetica;}
}
</style>
</head>
<body>
<div class="title">
<div class="svg-wrapper">
<svg height="66" width="250" xmlns="http://www.w3.org/2000/svg">
<rect id="shape" height="66" width="250" />
<div id="text" title="Replay">
<h1>IN TIME</h1>
</div>
</svg>
</div>
<div class="before">
<a href="#" id="before">before</a>
</div>
</div>
<canvas id="live2dcanvas" width="200" height="266.6"></canvas>
<canvas id="canvas" height="300"></canvas>
</body>
<!--<script src="http://wechatfe.github.io/vconsole/lib/vconsole.min.js?v=3.0.0.0"></script>
<script type="text/javascript">
window.vConsole = new window.VConsole()
</script>-->
<script type="text/javascript" src="js/bundle.js?3d053df9f21c7b6d1339"></script>
<script type="text/javascript">
window.onresize = function() {
location.reload()
}
window.onload = function() {
var nextUrl = 'http://veveue.com/index-v1.html'
// if(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
// location.href = nextUrl
// } else if(/(Android)/i.test(navigator.userAgent)) {
// location.href = nextUrl
// }
document.getElementById('before').href = nextUrl;
document.getElementById('canvas').width = document.body.clientWidth / 2;
loadlive2d("live2dcanvas", '../assets/shizuku/shizuku.model.json', 2, 0.5, 0.8, 1);
new AudioVisualizer().init();
}
var AudioVisualizer = function() {
this.file = './assets/123.m4a';
this.canvas = document.getElementById('canvas');
this.ctx = this.canvas.getContext('2d');
this.gradient = this.ctx.createLinearGradient(0, 0, 0, 300);
this.cwidth = this.canvas.width / 2;
this.cheight = this.canvas.height - 2;
this.meterWidth = 5; //能量条的宽度
this.gap = 1; //能量条的间距
this.btn = document.getElementById('text');
try {
this.atx = new AudioContext();
} catch(error) {
var audio = document.createElement('audio');
audio.src = 'http://ohjr3xer5.bkt.clouddn.com/12.mp3';
audio.play();
document.addEventListener('touchstart', function() {
audio.play();
}, false);
return false
}
this.flg = true;
this.arraybuffers = null;
this.ctx.translate(this.cwidth, 0);
};
AudioVisualizer.prototype = {
init: function() {
this._loadAudio();
},
_drawzer: function(a) {
var source = null;
var self = this
self.atx.decodeAudioData(a, function(buffer) {
var analyser = self.atx.createAnalyser();
source = self.atx.createBufferSource();
source.connect(analyser);
analyser.connect(self.atx.destination);
source.buffer = buffer;
source.start(0);
self.btn.addEventListener('click', function() {
source.stop(0);
self.file = './assets/In Time.mp3';
self.init();
}, false)
var capYPositionArray = [];
self.gradient.addColorStop(1, '#0f0');
self.gradient.addColorStop(0.5, '#ff0');
self.gradient.addColorStop(0, '#f00');
self._drawSpectrum(analyser, capYPositionArray);
}, function(e) {
console.info('处理出错');
});
},
_drawSpectrum: function(analyser, capYPositionArray) {
var self = this,
capHeight = 2,
capStyle = '#fff',
meterNum = self.cwidth / (self.meterWidth + self.gap);
var array = new Uint8Array(analyser.frequencyBinCount);
analyser.getByteFrequencyData(array);
var step = Math.round(array.length / meterNum);
self.ctx.clearRect(-self.cwidth, 0, self.cwidth * 2, self.cheight);
for(var i = 0; i < meterNum; i++) {
var value = array[i * step];
if(capYPositionArray.length < Math.round(meterNum)) {
capYPositionArray.push(value);
}
self.ctx.fillStyle = capStyle;
if((value - 0.1) < capYPositionArray[i]) {
self.ctx.fillRect(i * (self.meterWidth + self.gap), self.cheight - (--capYPositionArray[i]), self.meterWidth, capHeight);
self.ctx.fillRect(-i * (self.meterWidth + self.gap), self.cheight - (--capYPositionArray[i]), self.meterWidth, capHeight);
} else {
self.ctx.fillRect(i * (self.meterWidth + self.gap), self.cheight - value, self.meterWidth, capHeight);
self.ctx.fillRect(-i * (self.meterWidth + self.gap), self.cheight - value, self.meterWidth, capHeight);
capYPositionArray[i] = value;
}
self.ctx.fillStyle = self.gradient;
self.ctx.fillRect(i * (self.meterWidth + self.gap), self.cheight - value + capHeight, self.meterWidth, self.cheight);
self.ctx.fillRect(-i * (self.meterWidth + self.gap), self.cheight - value + capHeight, self.meterWidth, self.cheight);
}
requestAnimationFrame(function() {
self._drawSpectrum(analyser, capYPositionArray);
});
},
_loadAudio: function() {
var self = this;
if(self.flg) {
self.flg = false
var request = new XMLHttpRequest();
request.open('GET', self.file, true);
request.responseType = 'arraybuffer';
request.onload = function() {
setTimeout(function() {
self.flg = true
}, 1000)
var arraybuffer = request.response;
self._drawzer(arraybuffer)
}
request.send();
}
}
}
</script>
</html>