efront 3.35.1 → 3.35.2
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/#loader.js +4 -1
- package/coms/basic/Tree.js +1 -1
- package/coms/basic_/#checkPromise.js +9 -0
- package/coms/basic_/Array2.js +57 -5
- package/coms/basic_/Promise.js +5 -5
- package/coms/compile/Program.js +34 -26
- package/coms/zimoli/active.js +2 -2
- package/coms/zimoli/appendChild.js +17 -14
- package/coms/zimoli/cross.js +3 -0
- package/coms/zimoli/css.js +6 -9
- package/coms/zimoli/dispatch.js +2 -1
- package/coms/zimoli/grid.js +1 -2
- package/coms/zimoli/list.js +1 -16
- package/coms/zimoli/menu.js +0 -1
- package/coms/zimoli/once.js +1 -1
- package/coms/zimoli/render.js +2 -1
- package/coms/zimoli/tree.js +1 -1
- package/docs/index.html +1 -1
- package/docs/main.xht +3 -2
- package/docs/mark.xht +1 -1
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/apps/impact/main.html +0 -3
- package/apps/impact/main.js +0 -321
- package/apps/impact/main.less +0 -26
package/apps/impact/main.html
DELETED
package/apps/impact/main.js
DELETED
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
var page = div();
|
|
2
|
-
page.innerHTML = Main;
|
|
3
|
-
class Renderer {
|
|
4
|
-
PARTICLE_COUNT = 150;
|
|
5
|
-
PARTICLE_RADIUS = 6;
|
|
6
|
-
MAX_ROTATION_ANGLE = Math.PI / 60;
|
|
7
|
-
TRANSLATION_COUNT = 500;
|
|
8
|
-
constructor(strategy) {
|
|
9
|
-
if (strategy) {
|
|
10
|
-
this.init(strategy);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
init(strategy) {
|
|
16
|
-
this.setParameters(strategy);
|
|
17
|
-
this.createParticles();
|
|
18
|
-
this.setupFigure();
|
|
19
|
-
this.reconstructMethod();
|
|
20
|
-
this.bindEvent();
|
|
21
|
-
this.drawFigure();
|
|
22
|
-
}
|
|
23
|
-
setParameters(strategy) {
|
|
24
|
-
|
|
25
|
-
this.container = page;
|
|
26
|
-
var offset = getScreenPosition(this.container);
|
|
27
|
-
this.width = offset.width;
|
|
28
|
-
this.height = offset.height;
|
|
29
|
-
var canvas = this.canvas = document.querySelector('canvas');
|
|
30
|
-
canvas.width = this.width;
|
|
31
|
-
canvas.height = this.height;
|
|
32
|
-
this.context = this.canvas.getContext('2d');
|
|
33
|
-
|
|
34
|
-
this.center = { x: this.width / 2, y: this.height / 2 };
|
|
35
|
-
|
|
36
|
-
this.rotationX = this.MAX_ROTATION_ANGLE;
|
|
37
|
-
this.rotationY = this.MAX_ROTATION_ANGLE;
|
|
38
|
-
this.strategyIndex = 0;
|
|
39
|
-
this.translationCount = 0;
|
|
40
|
-
this.theta = 0;
|
|
41
|
-
|
|
42
|
-
this.strategies = strategy.getStrategies();
|
|
43
|
-
this.particles = [];
|
|
44
|
-
}
|
|
45
|
-
createParticles() {
|
|
46
|
-
for (var i = 0; i < this.PARTICLE_COUNT; i++) {
|
|
47
|
-
this.particles.push(new Partice(this.center));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
reconstructMethod() {
|
|
51
|
-
this.setupFigure = this.setupFigure.bind(this);
|
|
52
|
-
this.drawFigure = this.drawFigure.bind(this);
|
|
53
|
-
this.changeAngle = this.changeAngle.bind(this);
|
|
54
|
-
}
|
|
55
|
-
bindEvent() {
|
|
56
|
-
on('click')(this.container, this.setupFigure);
|
|
57
|
-
on('mousemove')(this.container, this.changeAngle);
|
|
58
|
-
}
|
|
59
|
-
changeAngle(event) {
|
|
60
|
-
var offset = getScreenPosition(this.container),
|
|
61
|
-
x = event.clientX - offset.left,
|
|
62
|
-
y = event.clientY - offset.top;
|
|
63
|
-
|
|
64
|
-
this.rotationX = (this.center.y - y) / this.center.y * this.MAX_ROTATION_ANGLE;
|
|
65
|
-
this.rotationY = (this.center.x - x) / this.center.x * this.MAX_ROTATION_ANGLE;
|
|
66
|
-
}
|
|
67
|
-
setupFigure() {
|
|
68
|
-
for (var i = 0, length = this.particles.length; i < length; i++) {
|
|
69
|
-
this.particles[i].setAxis(this.strategies[this.strategyIndex]());
|
|
70
|
-
}
|
|
71
|
-
if (++this.strategyIndex == this.strategies.length) {
|
|
72
|
-
this.strategyIndex = 0;
|
|
73
|
-
}
|
|
74
|
-
this.translationCount = 0;
|
|
75
|
-
}
|
|
76
|
-
drawFigure() {
|
|
77
|
-
requestAnimationFrame(this.drawFigure);
|
|
78
|
-
analyser.getFloatTimeDomainData(arr);
|
|
79
|
-
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
80
|
-
|
|
81
|
-
for (var cx = 0, dx = this.particles.length; cx < dx; cx++) {
|
|
82
|
-
var axis = this.particles[cx].getAxis2D(this.theta);
|
|
83
|
-
|
|
84
|
-
this.context.beginPath();
|
|
85
|
-
this.context.fillStyle = axis.color;
|
|
86
|
-
this.context.arc(axis.x + (axis.x - this.center.x) * (arr[cx % arr.length]) | 0, axis.y + (axis.y - this.center.y) * (arr[cx % arr.length]) | 0, this.PARTICLE_RADIUS, 0, Math.PI * 2);
|
|
87
|
-
this.context.fill();
|
|
88
|
-
}
|
|
89
|
-
// console.log(this.context);
|
|
90
|
-
this.theta++;
|
|
91
|
-
this.theta %= 360;
|
|
92
|
-
|
|
93
|
-
for (var cx = 0, dx = this.particles.length; cx < dx; cx++) {
|
|
94
|
-
this.particles[cx].rotateX(this.rotationX);
|
|
95
|
-
this.particles[cx].rotateY(this.rotationY);
|
|
96
|
-
}
|
|
97
|
-
this.translationCount++;
|
|
98
|
-
this.translationCount %= this.TRANSLATION_COUNT;
|
|
99
|
-
|
|
100
|
-
if (this.translationCount == 0) {
|
|
101
|
-
this.setupFigure();
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
class Strategy {
|
|
106
|
-
SCATTER_RADIUS = 200;
|
|
107
|
-
CONE_ASPECT_RATIO = 5;
|
|
108
|
-
RING_COUNT = 5;
|
|
109
|
-
constructor() {
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
getStrategies() {
|
|
114
|
-
var strategies = [];
|
|
115
|
-
|
|
116
|
-
for (var i in this) {
|
|
117
|
-
if (this[i] === this.getStrategies || typeof this[i] != 'function') {
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
strategies.push(this[i].bind(this));
|
|
121
|
-
}
|
|
122
|
-
return strategies;
|
|
123
|
-
}
|
|
124
|
-
createSphere() {
|
|
125
|
-
var cosTheta = Math.random() * 2 - 1,
|
|
126
|
-
sinTheta = Math.sqrt(1 - cosTheta * cosTheta),
|
|
127
|
-
phi = Math.random() * 2 * Math.PI;
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
x: this.SCATTER_RADIUS * sinTheta * Math.cos(phi),
|
|
131
|
-
y: this.SCATTER_RADIUS * sinTheta * Math.sin(phi),
|
|
132
|
-
z: this.SCATTER_RADIUS * cosTheta,
|
|
133
|
-
hue: Math.round(phi / Math.PI * 30)
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
createTorus() {
|
|
137
|
-
var theta = Math.random() * Math.PI * 2,
|
|
138
|
-
x = this.SCATTER_RADIUS + this.SCATTER_RADIUS / 6 * Math.cos(theta),
|
|
139
|
-
y = this.SCATTER_RADIUS / 6 * Math.sin(theta),
|
|
140
|
-
phi = Math.random() * Math.PI * 2;
|
|
141
|
-
|
|
142
|
-
return {
|
|
143
|
-
x: x * Math.cos(phi),
|
|
144
|
-
y: y,
|
|
145
|
-
z: x * Math.sin(phi),
|
|
146
|
-
hue: Math.round(phi / Math.PI * 30)
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
createCone() {
|
|
150
|
-
var status = Math.random() > 1 / 3,
|
|
151
|
-
x,
|
|
152
|
-
y,
|
|
153
|
-
phi = Math.random() * Math.PI * 2,
|
|
154
|
-
rate = Math.tan(30 / 180 * Math.PI) / this.CONE_ASPECT_RATIO;
|
|
155
|
-
|
|
156
|
-
if (status) {
|
|
157
|
-
y = this.SCATTER_RADIUS * (1 - Math.random() * 2);
|
|
158
|
-
x = (this.SCATTER_RADIUS - y) * rate;
|
|
159
|
-
} else {
|
|
160
|
-
y = -this.SCATTER_RADIUS;
|
|
161
|
-
x = this.SCATTER_RADIUS * 2 * rate * Math.random();
|
|
162
|
-
}
|
|
163
|
-
return {
|
|
164
|
-
x: x * Math.cos(phi),
|
|
165
|
-
y: y,
|
|
166
|
-
z: x * Math.sin(phi),
|
|
167
|
-
hue: Math.round(phi / Math.PI * 30)
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
createVase() {
|
|
171
|
-
var theta = Math.random() * Math.PI,
|
|
172
|
-
x = Math.abs(this.SCATTER_RADIUS * Math.cos(theta) / 2) + this.SCATTER_RADIUS / 8,
|
|
173
|
-
y = this.SCATTER_RADIUS * Math.cos(theta) * 1.2,
|
|
174
|
-
phi = Math.random() * Math.PI * 2;
|
|
175
|
-
|
|
176
|
-
return {
|
|
177
|
-
x: x * Math.cos(phi),
|
|
178
|
-
y: y,
|
|
179
|
-
z: x * Math.sin(phi),
|
|
180
|
-
hue: Math.round(phi / Math.PI * 30)
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
class Partice {
|
|
185
|
-
constructor(center) {
|
|
186
|
-
this.center = center;
|
|
187
|
-
this.init();
|
|
188
|
-
}
|
|
189
|
-
SPRING = 0.01;
|
|
190
|
-
FRICTION = 0.9;
|
|
191
|
-
FOCUS_POSITION = 300;
|
|
192
|
-
COLOR = 'hsl(%hue, 100%, 70%)';
|
|
193
|
-
init() {
|
|
194
|
-
this.x = 0;
|
|
195
|
-
this.y = 0;
|
|
196
|
-
this.z = 0;
|
|
197
|
-
this.vx = 0;
|
|
198
|
-
this.vy = 0;
|
|
199
|
-
this.vz = 0;
|
|
200
|
-
this.color;
|
|
201
|
-
}
|
|
202
|
-
setAxis(axis) {
|
|
203
|
-
this.translating = true;
|
|
204
|
-
this.nextX = axis.x;
|
|
205
|
-
this.nextY = axis.y;
|
|
206
|
-
this.nextZ = axis.z;
|
|
207
|
-
this.hue = axis.hue;
|
|
208
|
-
}
|
|
209
|
-
rotateX(angle) {
|
|
210
|
-
var sin = Math.sin(angle),
|
|
211
|
-
cos = Math.cos(angle),
|
|
212
|
-
nextY = this.nextY * cos - this.nextZ * sin,
|
|
213
|
-
nextZ = this.nextZ * cos + this.nextY * sin,
|
|
214
|
-
y = this.y * cos - this.z * sin,
|
|
215
|
-
z = this.z * cos + this.y * sin;
|
|
216
|
-
|
|
217
|
-
this.nextY = nextY;
|
|
218
|
-
this.nextZ = nextZ;
|
|
219
|
-
this.y = y;
|
|
220
|
-
this.z = z;
|
|
221
|
-
}
|
|
222
|
-
rotateY(angle) {
|
|
223
|
-
var sin = Math.sin(angle),
|
|
224
|
-
cos = Math.cos(angle),
|
|
225
|
-
nextX = this.nextX * cos - this.nextZ * sin,
|
|
226
|
-
nextZ = this.nextZ * cos + this.nextX * sin,
|
|
227
|
-
x = this.x * cos - this.z * sin,
|
|
228
|
-
z = this.z * cos + this.x * sin;
|
|
229
|
-
|
|
230
|
-
this.nextX = nextX;
|
|
231
|
-
this.nextZ = nextZ;
|
|
232
|
-
this.x = x;
|
|
233
|
-
this.z = z;
|
|
234
|
-
}
|
|
235
|
-
rotateZ(angle) {
|
|
236
|
-
var sin = Math.sin(angle),
|
|
237
|
-
cos = Math.cos(angle),
|
|
238
|
-
nextX = this.nextX * cos - this.nextY * sin,
|
|
239
|
-
nextY = this.nextY * cos + this.nextX * sin,
|
|
240
|
-
x = this.x * cos - this.y * sin,
|
|
241
|
-
y = this.y * cos + this.x * sin;
|
|
242
|
-
|
|
243
|
-
this.nextX = nextX;
|
|
244
|
-
this.nextY = nextY;
|
|
245
|
-
this.x = x;
|
|
246
|
-
this.y = y;
|
|
247
|
-
}
|
|
248
|
-
getAxis3D() {
|
|
249
|
-
this.vx += (this.nextX - this.x) * this.SPRING;
|
|
250
|
-
this.vy += (this.nextY - this.y) * this.SPRING;
|
|
251
|
-
this.vz += (this.nextZ - this.z) * this.SPRING;
|
|
252
|
-
|
|
253
|
-
this.vx *= this.FRICTION;
|
|
254
|
-
this.vy *= this.FRICTION;
|
|
255
|
-
this.vz *= this.FRICTION;
|
|
256
|
-
|
|
257
|
-
this.x += this.vx;
|
|
258
|
-
this.y += this.vy;
|
|
259
|
-
this.z += this.vz;
|
|
260
|
-
|
|
261
|
-
return { x: this.x, y: this.y, z: this.z };
|
|
262
|
-
}
|
|
263
|
-
getAxis2D(theta) {
|
|
264
|
-
var axis = this.getAxis3D(),
|
|
265
|
-
scale = this.FOCUS_POSITION / (this.FOCUS_POSITION + axis.z);
|
|
266
|
-
|
|
267
|
-
return { x: this.center.x + axis.x * scale, y: this.center.y - axis.y * scale, color: this.COLOR.replace('%hue', this.hue + theta) };
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function play(url) {
|
|
273
|
-
var AudioContext = window.mozAudioContext || window.webkitAudioContext || window.AudioContext;
|
|
274
|
-
if (!AudioContext) {
|
|
275
|
-
alert("error", "不支持的浏览器!");
|
|
276
|
-
throw "不支持的浏览器";
|
|
277
|
-
}
|
|
278
|
-
var xhr = cross("get", url).done(function () {
|
|
279
|
-
console.log(xhr.response);
|
|
280
|
-
audioContext.decodeAudioData(xhr.response, function (buffer) {
|
|
281
|
-
var source = audioContext.createBufferSource();
|
|
282
|
-
source.buffer = buffer;
|
|
283
|
-
source.connect(analyser);
|
|
284
|
-
analyser.connect(gainNode);
|
|
285
|
-
gainNode.connect(audioContext.destination);
|
|
286
|
-
|
|
287
|
-
source.start ? source.start(0) : source.noteOn(0);
|
|
288
|
-
}, alert.bind("error"))
|
|
289
|
-
});
|
|
290
|
-
xhr.responseType = "arraybuffer";
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
var audioContext = new AudioContext;
|
|
294
|
-
var gainNode = audioContext.createGain ? audioContext.createGain() : audioContext.createGainNode();
|
|
295
|
-
var analyser = audioContext.createAnalyser();
|
|
296
|
-
analyser.fftSize = 512;
|
|
297
|
-
var arr = new Float32Array(analyser.frequencyBinCount);
|
|
298
|
-
var arrFloat = new Float32Array(analyser.frequencyBinCount);
|
|
299
|
-
var seeAudio = function () {
|
|
300
|
-
var canvas = document.querySelector("canvas");
|
|
301
|
-
canvas.width = page.offsetWidth;
|
|
302
|
-
canvas.height = page.offsetHeight;
|
|
303
|
-
var context = canvas.getContext("2d");
|
|
304
|
-
context.strokeStyle = "#ffffff";
|
|
305
|
-
var run = function () {
|
|
306
|
-
requestAnimationFrame(run);
|
|
307
|
-
analyser.getFloatTimeDomainData(arrFloat);
|
|
308
|
-
view$audio(context, arrFloat);
|
|
309
|
-
}
|
|
310
|
-
requestAnimationFrame(run);
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
once("append")(page, function () {
|
|
314
|
-
seeAudio();
|
|
315
|
-
// new Renderer(new Strategy);
|
|
316
|
-
});
|
|
317
|
-
render(page, { gainNode });
|
|
318
|
-
function main() {
|
|
319
|
-
play("http://fs.open.kugou.com/ef34b2e46b9d7e8b2199c4943d2eb81c/5c830a93/G073/M04/17/11/iQ0DAFePd5OIBXTgAA98qfjcK2YAAAacACmTFkAD3zB338.m4a");
|
|
320
|
-
return page;
|
|
321
|
-
}
|
package/apps/impact/main.less
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
& {
|
|
2
|
-
color: #fff;
|
|
3
|
-
@background-size: 20px;
|
|
4
|
-
@mask-color: #ccc;
|
|
5
|
-
background-image: linear-gradient(45deg, @mask-color, 25%, @mask-color, 25%, rgba(0, 0, 0, 0), 75%, rgba(0, 0, 0, 0), 75%, @mask-color), linear-gradient(45deg, @mask-color, 25%, @mask-color, 25%, rgba(0, 0, 0, 0), 75%, rgba(0, 0, 0, 0), 75%, @mask-color);
|
|
6
|
-
background-size: 20px 20px;
|
|
7
|
-
background-repeat: repeat;
|
|
8
|
-
background-size: @background-size @background-size;
|
|
9
|
-
background-position: 0 0, @background-size/2 @background-size/2;
|
|
10
|
-
background: black;
|
|
11
|
-
>* {
|
|
12
|
-
position: relative;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
&,
|
|
17
|
-
canvas {
|
|
18
|
-
width: 100%;
|
|
19
|
-
height: 100%;
|
|
20
|
-
position: absolute;
|
|
21
|
-
left: 0;
|
|
22
|
-
right: 0;
|
|
23
|
-
bottom: 0;
|
|
24
|
-
right: 0;
|
|
25
|
-
display: block;
|
|
26
|
-
}
|