Skip to content

Commit

Permalink
Add a script to test the image output from NodeJS
Browse files Browse the repository at this point in the history
  • Loading branch information
prantlf committed Jul 30, 2015
1 parent 85991f7 commit a7c1c07
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"lodash": "~3.7.0"
},
"devDependencies": {
"canvas": "1.2.7",
"jison": "0.4.13"
},
"scripts": {
Expand Down
26 changes: 26 additions & 0 deletions test/nodejs.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Writes a testing PNG diagram to the standard output
// Usage: node nodejs.test.js > piracy.png
var Canvas = require('canvas'),
nomnoml = require('../dist/nomnoml'),
canvas = new Canvas(640, 480),
source = '\
[Pirate|eyeCount: Int|raid();pillage()|\n\
[beard]--[parrot]\n\
[beard]-:>[foul mouth]\n\
]\n\
\n\
[<abstract>Marauder]<:--[Pirate]\n\
[Pirate]- 0..7[mischief]\n\
[jollyness]->[Pirate]\n\
[jollyness]->[rum]\n\
[jollyness]->[singing]\n\
[Pirate]-> *[rum|tastiness: Int|swig()]\n\
[Pirate]->[singing]\n\
[singing]<->[rum]\n\
\n\
[<start>st]->[<state>plunder]\n\
[plunder]->[<choice>more loot]\n\
[more loot]->[st]\n\
[more loot] no ->[<end>e]\n';
nomnoml.draw(canvas, source);
canvas.pngStream().pipe(process.stdout);

0 comments on commit a7c1c07

Please sign in to comment.