-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessor.js
More file actions
47 lines (40 loc) · 1.49 KB
/
processor.js
File metadata and controls
47 lines (40 loc) · 1.49 KB
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
let processor = {
timerCallback: function () {
// if (this.video.paused || this.video.ended) {
// return;
// }
this.computeFrame();
let self = this;
setTimeout(function () {
self.timerCallback();
}, 0);
},
doLoad: function () {
this.video = document.getElementById('video');
this.canvas = document.getElementById('smoke-canvas');
this.canvasCtx = canvas.getContext('2d');
this.blendedCanvas = document.getElementById('blended-canvas');
this.blendedCtx = blendedCanvas.getContext('2d');
this.video.setAttribute('crossOrigin', 'Anonymous');
this.canvas.setAttribute('crossOrigin', 'Anonymous');
this.blendedCanvas.setAttribute('crossOrigin', 'Anonymous');
let self = this;
this.video.addEventListener("play", function () {
self.blendedCanvas.width = innerWidth;
self.blendedCanvas.height = innerHeight;
self.width = self.video.width;
self.height = self.video.height;
self.timerCallback();
}, false);
},
computeFrame: function () {
this.blendedCtx.drawImage(this.video, 0, 0, innerWidth, innerHeight);
this.blendedCtx.globalAlpha = blendAlpha;
this.blendedCtx.drawImage(canvas, 0, 0, innerWidth, innerHeight);
this.blendedCtx.globalAlpha = 1.0;
return;
}
};
document.addEventListener("DOMContentLoaded", () => {
processor.doLoad();
});