-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpivi.js
35 lines (33 loc) · 967 Bytes
/
pivi.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
#!/usr/bin/env node
// perhaps include it later...
// var canvas = require("canvas");
var es = require("event-stream");
var parse = require("./lib/grammar.js").parse;
// perhaps include canvas later?
// var sc = require("./lib/streamCanvas.js");
var sr = require("./lib/streamRune.js");
var argv = require("yargs")
.usage("echo 'line (0 0) (200 200)' | $0 [options]")
.default("f",null)
.describe("f", "The output file that gets generated")
.default("a",false)
.describe("a","create an animated gif")
.help("h")
.argv;
// var api = require("./lib/api.js");
if(argv.a){
if(argv.f == "./out%d.png"){
argv.f = "out.gif";
}
process.stdin
.pipe(es.split())
.pipe(es.mapSync(parse))
.pipe(sr())
.pipe(api.createAnimationProcessor(argv.f));
} else {
process.stdin
.pipe(es.split())
.pipe(es.mapSync(parse))
.pipe(sr(argv.f))
.pipe(process.stdout);
}