-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdocode.js
27 lines (23 loc) · 1.11 KB
/
docode.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
// This is the docode module, it provides a simple api for creating documentation of a p5 sketch
var docode = {
renderScreenshots: function(numOfImgs, source, target, interval) {
var path = require('path');
var renderer = path.join(__dirname, 'renderer.js');
var spawnSync = require('child_process').spawnSync;
var args = [renderer, source, target, numOfImgs, interval];
var phantomjs = require('phantomjs2').path;
var spawnSync = require('child_process').spawnSync;
spawnSync(phantomjs, args, {stdio: 'ignore'});
},
renderGif: function(name, source, target, interval) {
var execSync = require('child_process').execSync;
var cmd = "convert -delay " + interval + " -loop 0 " + source + " " + target;
execSync(cmd, { stdio: 'ignore' });
},
renderVideo: function(name, source, target, interval) {
var execSync = require('child_process').execSync;
var cmd = "ffmpeg -framerate 24 -pattern_type sequence -i 'docode/_temp/sketch%02d.png' -f mp4 -c:v libx264 -pix_fmt yuv420p docode/video/" + target + ".mp4";
execSync(cmd, { stdio: 'ignore' });
}
};
exports.docode = docode;