efront 3.25.16 → 3.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/coms/basic/Matrix.js +1 -0
- package/coms/basic/Speed.js +3 -1
- package/coms/{zimoli → basic}/extendIfNeeded.js +2 -0
- package/coms/basic/extendIfOccurs.js +21 -0
- package/coms/basic/getIndexFromOrderedArray.js +7 -0
- package/coms/kugou/playList.html +5 -1
- package/coms/kugou/playList.js +6 -1
- package/coms/kugou/player.js +29 -1
- package/coms/third-party/NoSleep.js +316 -0
- package/coms/third-party/Voronoi.js +1722 -0
- package/coms/third-party/deflate.js +1691 -0
- package/coms/{zimoli → third-party}/inflate.js +0 -0
- package/coms/third-party//344/273/243/347/240/201/346/235/245/346/272/220.txt +6 -0
- package/coms/zimoli/Voronoi.js +1 -1722
- package/coms/zimoli/audio.js +1 -1
- package/coms/zimoli/data.js +8 -0
- package/coms/zimoli/model.js +5 -0
- package/coms/zimoli/on.js +1 -0
- package/coms/zimoli/slider.js +1 -1
- package/coms/zimoli/water.js +104 -156
- package/coms/zimoli/water_test.js +26 -2
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/coms/reptile/queue.js +0 -1
- package/coms/zimoli/deflate.js +0 -1691
package/coms/zimoli/audio.js
CHANGED
|
@@ -88,8 +88,8 @@ async function start() {
|
|
|
88
88
|
var animate = () => {
|
|
89
89
|
this.getTimeDomainData.call(analyser, dancingArray);
|
|
90
90
|
cast(this, dancingArray);
|
|
91
|
-
analyser.frame = requestAnimationFrame(animate);
|
|
92
91
|
this.onprocess instanceof Function && this.onprocess(dancingArray);
|
|
92
|
+
analyser.frame = requestAnimationFrame(animate);
|
|
93
93
|
};
|
|
94
94
|
animate();
|
|
95
95
|
this.running = true;
|
package/coms/zimoli/data.js
CHANGED
|
@@ -1023,6 +1023,14 @@ var data = {
|
|
|
1023
1023
|
extend(instance, data);
|
|
1024
1024
|
return this.setInstance(instanceId, instance, rememberWithStorage);
|
|
1025
1025
|
},
|
|
1026
|
+
/**
|
|
1027
|
+
* 仅初始化,不覆盖
|
|
1028
|
+
*/
|
|
1029
|
+
initInstance(instanceId, data, rememberWithStorage = 0) {
|
|
1030
|
+
var item = getItem(instanceId);
|
|
1031
|
+
if (!isEmpty(item)) return;
|
|
1032
|
+
return this.setInstance(instanceId, data, rememberWithStorage);
|
|
1033
|
+
},
|
|
1026
1034
|
switchInstance(instanceId, key, rememberWithStorage = 0) {
|
|
1027
1035
|
var instance = this.getInstance(instanceId);
|
|
1028
1036
|
if (key === true || key === false || isEmpty(key)) {
|
package/coms/zimoli/model.js
CHANGED
package/coms/zimoli/on.js
CHANGED
package/coms/zimoli/slider.js
CHANGED
|
@@ -123,13 +123,13 @@ function slider(autoplay, circle = true) {
|
|
|
123
123
|
var now = +Speed.now();
|
|
124
124
|
if (abs(current_index + negative_index) < 1.25 / width)
|
|
125
125
|
return reshape(-negative_index, false);
|
|
126
|
-
timer_animate = requestAnimationFrame(animate);
|
|
127
126
|
var temp_index = current_index;
|
|
128
127
|
while (savedtime < now) {
|
|
129
128
|
temp_index = (temp_index * 11 - negative_index) / 12;
|
|
130
129
|
savedtime += 6;
|
|
131
130
|
}
|
|
132
131
|
reshape(temp_index);
|
|
132
|
+
timer_animate = requestAnimationFrame(animate);
|
|
133
133
|
};
|
|
134
134
|
var park = function () {
|
|
135
135
|
direction = 0;
|
package/coms/zimoli/water.js
CHANGED
|
@@ -1,100 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// 检测背景图
|
|
22
|
-
if (!settings.image.length) {
|
|
23
|
-
return false;
|
|
1
|
+
class WaterRipple {
|
|
2
|
+
/**
|
|
3
|
+
* @type {HTMLCanvasElement}
|
|
4
|
+
*/
|
|
5
|
+
canvas = null;
|
|
6
|
+
src = ""
|
|
7
|
+
dropRadius = 3 // 波源半径大小
|
|
8
|
+
delay = 1
|
|
9
|
+
attenuation = 5
|
|
10
|
+
maxAmplitude = 1024 // 最大振幅
|
|
11
|
+
sourceAmplitude = 512 // 震源振幅
|
|
12
|
+
autoDisturb = true;
|
|
13
|
+
animateId = 0;
|
|
14
|
+
intervalId = 0;
|
|
15
|
+
loadId = 0;
|
|
16
|
+
ripple_map = [];
|
|
17
|
+
last_map = [];
|
|
18
|
+
destroy() {
|
|
19
|
+
this.stop();
|
|
24
20
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
delay = settings.delay * 1000,
|
|
30
|
-
attenuation = settings.attenuation, // 衰减级别
|
|
31
|
-
maxAmplitude = settings.maxAmplitude, // 最大振幅
|
|
32
|
-
sourceAmplitude = settings.sourceAmplitude,
|
|
33
|
-
half_width = width >> 1,
|
|
34
|
-
half_height = height >> 1,
|
|
35
|
-
amplitude_size = width * (height + 2) * 2,
|
|
36
|
-
old_index = width,
|
|
37
|
-
new_index = width * (height + 3),
|
|
38
|
-
map_index, // 振幅数组索引
|
|
39
|
-
texture, // 原始图像像素信息
|
|
40
|
-
ripple, // 参数波纹的图像像素信息
|
|
41
|
-
image, // Image对象
|
|
42
|
-
autoRepeat, // 自动产生波源的重复事件
|
|
43
|
-
ripple_map = [],
|
|
44
|
-
last_map = [];
|
|
45
|
-
|
|
46
|
-
var canvas = element;
|
|
47
|
-
canvas.width = width;
|
|
48
|
-
canvas.height = height;
|
|
49
|
-
|
|
50
|
-
var ctx = canvas.getContext('2d');
|
|
51
|
-
ctx.fillStyle = settings.bgColor;
|
|
52
|
-
ctx.fillRect(0, 0, width, height);
|
|
53
|
-
// 加载图片
|
|
54
|
-
function loadImage() {
|
|
55
|
-
image = new Image();
|
|
56
|
-
image.src = settings.image;
|
|
57
|
-
if (image.complete) {
|
|
58
|
-
init.call(this);
|
|
59
|
-
} else {
|
|
60
|
-
image.onload = init;
|
|
61
|
-
}
|
|
21
|
+
stop() {
|
|
22
|
+
cancelAnimationFrame(this.animateId);
|
|
23
|
+
clearInterval(this.intervalId);
|
|
24
|
+
this.loadId = 0;
|
|
62
25
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
26
|
+
async init() {
|
|
27
|
+
var canvas = this.canvas;
|
|
28
|
+
var width = canvas.width,
|
|
29
|
+
height = canvas.height,
|
|
30
|
+
amplitude_size = width * (height + 2) * 2;
|
|
31
|
+
this.old_index = width;
|
|
32
|
+
this.new_index = width * (height + 3);
|
|
33
|
+
var ripple_map = this.ripple_map = new Array(amplitude_size);
|
|
34
|
+
var last_map = this.last_map = this.ripple_map.slice();
|
|
35
|
+
var ctx = canvas.getContext('2d');
|
|
36
|
+
ctx.fillRect(0,0,width,height);
|
|
37
|
+
var image = new Image();
|
|
38
|
+
image.src = this.src;
|
|
39
|
+
var loadId = ++this.loadId;
|
|
40
|
+
await awaitable(image);
|
|
41
|
+
if (loadId !== this.loadId) return false;
|
|
67
42
|
ctx.drawImage(image, 0, 0);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
ripple = ctx.getImageData(0, 0, width, height);
|
|
71
|
-
// 波幅数组初始化为0
|
|
43
|
+
this.texture = ctx.getImageData(0, 0, width, height);
|
|
44
|
+
this.ripple = ctx.getImageData(0, 0, width, height);
|
|
72
45
|
for (var i = 0; i < amplitude_size; i++) {
|
|
73
46
|
ripple_map[i] = last_map[i] = 0;
|
|
74
47
|
}
|
|
75
|
-
|
|
76
|
-
animate();
|
|
77
|
-
// 如果设置了自动产生波源,则随机参数波源
|
|
78
|
-
if (settings.auto) {
|
|
79
|
-
autoRepeat = setInterval(function () {
|
|
80
|
-
disturb(Math.random() * width, Math.random() * height);
|
|
81
|
-
}, delay);
|
|
82
|
-
disturb(Math.random() * width, Math.random() * height);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
48
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
49
|
+
start() {
|
|
50
|
+
var that = this;
|
|
51
|
+
if (that.autoDisturb) {
|
|
52
|
+
that.intervalId = setInterval(function () {
|
|
53
|
+
if (!that.canvas || !that.canvas.parentNode) return that.stop();
|
|
54
|
+
var { width, height } = that.canvas;
|
|
55
|
+
that.disturb(Math.random() * width, Math.random() * height);
|
|
56
|
+
}, that.delay * 1000);
|
|
57
|
+
}
|
|
58
|
+
// 动画主循环
|
|
59
|
+
var animate = async function () {
|
|
60
|
+
var { ripple, canvas } = that;
|
|
61
|
+
if (!canvas) return;
|
|
62
|
+
if (!ripple || ripple.width !== canvas.width || ripple.height !== canvas.height) {
|
|
63
|
+
if (await that.init() === false) return;
|
|
64
|
+
}
|
|
65
|
+
that.renderRipple();
|
|
66
|
+
that.animateId = requestAnimationFrame(animate);
|
|
67
|
+
};
|
|
68
|
+
animate();
|
|
91
69
|
}
|
|
92
|
-
|
|
93
70
|
// 在指定地点产生波源
|
|
94
|
-
|
|
71
|
+
disturb(circleX, circleY) {
|
|
95
72
|
// 将值向下取整
|
|
96
|
-
circleX
|
|
97
|
-
circleY
|
|
73
|
+
circleX |= 0;
|
|
74
|
+
circleY |= 0;
|
|
75
|
+
var dropRadius = this.dropRadius,
|
|
76
|
+
sourceAmplitude = this.sourceAmplitude,
|
|
77
|
+
width = this.canvas.width,
|
|
78
|
+
old_index = width,
|
|
79
|
+
ripple_map = this.ripple_map;
|
|
98
80
|
var maxDistanceX = circleX + dropRadius,
|
|
99
81
|
maxDistanceY = circleY + dropRadius;
|
|
100
82
|
for (var y = circleY - dropRadius; y < maxDistanceY; y++) {
|
|
@@ -103,40 +85,38 @@ function WaterRipple(element, settings) {
|
|
|
103
85
|
}
|
|
104
86
|
}
|
|
105
87
|
}
|
|
106
|
-
|
|
107
88
|
// 渲染下一帧
|
|
108
|
-
|
|
109
|
-
var
|
|
89
|
+
renderRipple() {
|
|
90
|
+
var temp = this.old_index,
|
|
110
91
|
deviation_x, // x水平方向偏移
|
|
111
92
|
deviation_y, // y竖直方向偏移
|
|
112
93
|
pixel_deviation, // 偏移后的ImageData对象像素索引
|
|
113
94
|
pixel_source; // 原始ImageData对象像素索引
|
|
114
95
|
|
|
115
96
|
// 交互索引 old_index, new_index
|
|
116
|
-
old_index = new_index;
|
|
117
|
-
new_index =
|
|
118
|
-
|
|
97
|
+
this.old_index = this.new_index;
|
|
98
|
+
this.new_index = temp;
|
|
99
|
+
// console.log(this.old_index,this.new_index)
|
|
100
|
+
var i = 0;
|
|
119
101
|
// 设置像素索引和振幅索引
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
_attenuation = attenuation,
|
|
135
|
-
_maxAmplitude = maxAmplitude;
|
|
102
|
+
this.map_index = this.old_index;
|
|
103
|
+
|
|
104
|
+
var _map_index = this.map_index,
|
|
105
|
+
_width = this.canvas.width,
|
|
106
|
+
_height = this.canvas.height,
|
|
107
|
+
_half_width = _width >> 1,
|
|
108
|
+
_half_height = _height >> 1,
|
|
109
|
+
_ripple_map = this.ripple_map,
|
|
110
|
+
_last_map = this.last_map,
|
|
111
|
+
_ripple_data = this.ripple.data, // 引用修改
|
|
112
|
+
_texture_data = this.texture.data, // 引用修改
|
|
113
|
+
_new_index = this.new_index,
|
|
114
|
+
_attenuation = this.attenuation,
|
|
115
|
+
_maxAmplitude = this.maxAmplitude;
|
|
136
116
|
|
|
137
117
|
|
|
138
118
|
// 渲染所有像素点
|
|
139
|
-
for (var y = 0; y <
|
|
119
|
+
for (var y = 0; y < _height; y++) {
|
|
140
120
|
for (var x = 0; x < _width; x++) {
|
|
141
121
|
var x_boundary = 0, judge = _map_index % _width;
|
|
142
122
|
if (judge == 0) {
|
|
@@ -179,7 +159,7 @@ function WaterRipple(element, settings) {
|
|
|
179
159
|
}
|
|
180
160
|
|
|
181
161
|
pixel_source = i * 4;
|
|
182
|
-
pixel_deviation = (deviation_x + (deviation_y *
|
|
162
|
+
pixel_deviation = (deviation_x + (deviation_y * _width)) * 4;
|
|
183
163
|
|
|
184
164
|
// 移动像素的RGBA信息
|
|
185
165
|
_ripple_data[pixel_source] = _texture_data[pixel_deviation];
|
|
@@ -192,11 +172,15 @@ function WaterRipple(element, settings) {
|
|
|
192
172
|
}
|
|
193
173
|
}
|
|
194
174
|
|
|
195
|
-
map_index = _map_index;
|
|
196
|
-
|
|
175
|
+
this.map_index = _map_index;
|
|
176
|
+
this.canvas.getContext('2d').putImageData(this.ripple, 0, 0);
|
|
197
177
|
}
|
|
178
|
+
calculAmplitude(index, old_amplitude) {
|
|
179
|
+
var attenuation = this.attenuation, // 衰减级别
|
|
180
|
+
map_index = this.map_index,
|
|
181
|
+
ripple_map = this.ripple_map,
|
|
182
|
+
width = this.canvas.width;
|
|
198
183
|
|
|
199
|
-
function calculAmplitude(index, old_amplitude) {
|
|
200
184
|
var x_boundary = 0, judge = map_index % width;
|
|
201
185
|
if (judge == 0) {
|
|
202
186
|
x_boundary = 1; // 左边边界
|
|
@@ -215,45 +199,9 @@ function WaterRipple(element, settings) {
|
|
|
215
199
|
return amplitude;
|
|
216
200
|
}
|
|
217
201
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
function main() {
|
|
225
|
-
|
|
226
|
-
//Settings - params for WaterRippleEffect
|
|
227
|
-
var settings = {
|
|
228
|
-
|
|
229
|
-
image: 'favicon.ico',
|
|
230
|
-
// image: '/{//asset.uusama.com/}@example/girl.png',//image path
|
|
231
|
-
dropRadius: 3,//radius of the ripple
|
|
232
|
-
width: 256,//width
|
|
233
|
-
height: 256,//height
|
|
234
|
-
delay: 1,//if auto param === true. 1 === 1 second delay for animation
|
|
235
|
-
auto: 1//if auto param === true, animation starts on it´s own
|
|
236
|
-
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
var canvas = document.createElement("canvas");
|
|
240
|
-
canvas.style.cursor = 'pointer';
|
|
241
|
-
var waterRippleEffect = new WaterRipple(canvas, settings);
|
|
242
|
-
|
|
243
|
-
//on click
|
|
244
|
-
onclick(canvas, function (e) {
|
|
245
|
-
var mouseX = e.layerX;
|
|
246
|
-
var mouseY = e.layerY;
|
|
247
|
-
waterRippleEffect.disturb(mouseX, mouseY);
|
|
248
|
-
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
//on mousemove
|
|
253
|
-
onmousemove(canvas, function (e) {
|
|
254
|
-
var mouseX = e.layerX;
|
|
255
|
-
var mouseY = e.layerY;
|
|
256
|
-
waterRippleEffect.disturb(mouseX, mouseY);
|
|
257
|
-
});
|
|
258
|
-
return canvas;
|
|
259
|
-
}
|
|
202
|
+
constructor(element, settings) {
|
|
203
|
+
// 合并设置
|
|
204
|
+
if (isElement(element) && /^canvas$/i.test(element.tagName)) this.canvas = element;
|
|
205
|
+
extendIfOccurs(this, settings);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
|
|
1
2
|
function main() {
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
var canvas = document.createElement("canvas");
|
|
4
|
+
canvas.style.cursor = 'pointer';
|
|
5
|
+
canvas.width = 256;
|
|
6
|
+
canvas.height = 256;
|
|
7
|
+
var waterRippleEffect = new water(canvas);
|
|
8
|
+
waterRippleEffect.src = "favicon.ico";
|
|
9
|
+
|
|
10
|
+
on("append")(canvas, function () {
|
|
11
|
+
waterRippleEffect.start();
|
|
12
|
+
});
|
|
13
|
+
on("remove")(canvas, function () {
|
|
14
|
+
waterRippleEffect.stop();
|
|
15
|
+
});
|
|
16
|
+
onclick(canvas, function (e) {
|
|
17
|
+
var mouseX = e.layerX;
|
|
18
|
+
var mouseY = e.layerY;
|
|
19
|
+
waterRippleEffect.disturb(mouseX, mouseY);
|
|
20
|
+
});
|
|
21
|
+
onmousemove(canvas, function (e) {
|
|
22
|
+
var mouseX = e.layerX;
|
|
23
|
+
var mouseY = e.layerY;
|
|
24
|
+
waterRippleEffect.disturb(mouseX, mouseY);
|
|
25
|
+
});
|
|
26
|
+
return canvas;
|
|
27
|
+
}
|