-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
60 lines (45 loc) · 1.67 KB
/
app.js
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
'use strict';
const debug = require('debug')('sketch:app');
const d3 = require('d3');
// in case page was saved, and reloaded
document.querySelector('#sketch-app').innerHTML = '';
let app = window.app || {};
app.polyfills = require('./polyfills.js');
app.control = require('./app-control.js');
app.data = require('./data.js');
app.sketch = require('./sketch.js');
app.transition = require('./transition.js');
app.domain = { x: [-10, 10], y: [-5, 5] };
app.structure = new app.data.Structure();
const set = new app.data.Set({ name: 'random', domain: app.domain})
.addRandom(10);
app.structure.addSet(set);
app.init = function() {
app.$selection = d3.select('#sketch-app');
app.control1 = new app.control.AppControl(app, 'app-control-1');
app.sketch1 = new app.sketch.Sketch({ top: app,
$parent: app.$selection,
structure: app.structure,
domain: app.domain });
app.sketch2 = new app.sketch.Sketch({ top: app,
$parent: app.$selection,
structure: app.structure,
domain: app.domain });
app.transition12 = new app.transition.Transition(
{ top: app,
$parent: app.$selection,
structure: app.structure,
domain: app.domain,
start: app.sketch1,
end: app.sketch2 });
app.update = function () {
// loop app.control1.update();
app.sketch1.update();
app.sketch2.update();
app.transition12.update();
};
}; // init
window.app = app;
window.addEventListener('DOMContentLoaded', function() {
app.init();
});