mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-05 09:55:20 +02:00
27 lines
785 B
JavaScript
27 lines
785 B
JavaScript
// usage:
|
|
// node avatar-json-to-dot.js /path/to/avatar-animaton.json > out.dot
|
|
//
|
|
// Then if you have graphviz installed you can run the following command to generate a png.
|
|
// dot -Tpng out.dot > out.png
|
|
|
|
var fs = require('fs');
|
|
var filename = process.argv[2];
|
|
|
|
function dumpNodes(node) {
|
|
node.children.forEach(function (child) {
|
|
console.log(' ' + node.id + ' -> ' + child.id + ';');
|
|
dumpNodes(child);
|
|
});
|
|
}
|
|
|
|
fs.readFile(filename, 'utf8', function (err, data) {
|
|
if (err) {
|
|
console.log('error opening ' + filename + ', err = ' + err);
|
|
} else {
|
|
var graph = JSON.parse(data);
|
|
console.log('digraph graphname {');
|
|
console.log(' rankdir = "LR";');
|
|
dumpNodes(graph.root);
|
|
console.log('}');
|
|
}
|
|
});
|