forked from skanaar/nomnoml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a script to test the image output from NodeJS
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
"lodash": "~3.7.0" | ||
}, | ||
"devDependencies": { | ||
"canvas": "1.2.7", | ||
"jison": "0.4.13" | ||
}, | ||
"scripts": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |