ps2js is a python tool to translate postscript into html5 canvas or paper.js code.
It works with simple PostScript images generated with cairo (eg. by converting an SVG with Inkscape).
Get the code by cloning the repo
$ git clone git://github.com/ffalcinelli/ps2js.git
Create a virtualenv for the project (I assume you're using virtualenvwrapper.sh) and install the requirements
$ mkvirtualenv ps2js
$ pip install -r requirements.txt
From inside the src dir, launch the script with -h option to read the help
$ /ps2js.py -h
usage: ps2js.py [-h] [-o OUTPUT_DIR] [-f {paperjs,html5}]
ps_files [ps_files ...]
Transform a PostScript into JavaScript
positional arguments:
ps_files
optional arguments:
-h, --help show this help message and exit
-o OUTPUT_DIR, --output-dir OUTPUT_DIR
Directory where results are to be stored
-f {paperjs,html5}, --format {paperjs,html5}
The format of the output code
Good luck! :-)
There are some postscripts in the samples folder. You can try to run this example
$ cd src
$ ./ps2js.py -o ../output -f paperjs ../samples/gnu.ps
And open the generated gnu.html to see the result
Not yet defined. I'm not so done for legal terms, but I think GPL is a good one.
Have to check for some usage of code (e.g. _AttributeDict from fabric) if is covered... Help me out! :-)
Make a TODO list- Check differences between fill in paper.js and html5 canvas (gnu.ps does not work in html5 format)
- Find a way to programmatically test the results
- Support other PS commands
- Improve the current ones