forked from jywarren/cyclogram
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprototype.js
More file actions
47 lines (43 loc) · 1.34 KB
/
prototype.js
File metadata and controls
47 lines (43 loc) · 1.34 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
import { createCyclogramCanvas, drawCyclogram } from "./modules/cyclogram.js";
import { loadVideo } from "./modules/video.js";
let processedVideoResponse = {};
let framesPerDay = 288/2; // remove nighttime hours, crudely
let dotSize = 6;
let i = 0;
let rowNumber = 0;
let colNumber = 0;
new p5(function(p5) {
p5.setup = function() {
const canvasOptions = {
width: 1000,
height: 400,
element: 'canvas',
};
createCyclogramCanvas(p5, canvasOptions);
const url = '../assets/river.mp4';
const loadOptions = { url, element: 'video' };
processedVideoResponse = loadVideo(p5, loadOptions);
}
p5.draw = function() {
const { video, frameRate, steps, density, x, y } = processedVideoResponse;
if (video) {
const drawOptions = {
video,
frameRate,
steps,
density,
myX: x || 100,
myY: y || 400,
framesPerDay,
dotSize,
i,
rowNumber,
colNumber,
};
const cyclogramResults = drawCyclogram(p5, drawOptions);
i = cyclogramResults.i;
rowNumber = cyclogramResults.rowNumber;
colNumber = cyclogramResults.colNumber;
}
}
});