This is a python module written in c. It turns an png image into a svg line drawing. The output is very suitable for vsg capable drawbots. We use it every day on blackstripes.nl.
This also comes with a command-line interface for using it, installed at the same time as the python module. Check blackstripes --help
for detailed usage.
This module exposes 3 drawing styles.
from blackstripes import sketchy
sketchy.draw("ali.png", # input
"ali_sketchy.svg", # output
1, # nibsize (line size in output svg)
100, # max line length
"#000000", # line color
0.32, # scaling factor
1, # line size (internal line size for calculations)
540, 1021, 0.7 # signature transform tx, ty, scale
)
Using the CLI:
blackstripes sketchy ali.png --output ali_sketchy.svg
- Calculate the brightness of the input image.
- Place the pen at pixel 0,0.
- Get a random line length between 10 and the max segment length.
- Evaluate 360 lines by making a 360 degree sweep with the selected line length.
- Get the line covering the largest average darkness in the input image.
- Draw this line white in the input image.
- Draw this line black in the ouput image.
- Calculate the brightness of the output image.
- Repeat from step 2 until the brightness of the output image is equal to the inpute image.
from blackstripes import crossed
crossed.draw("ali.png", # input
"ali_crossed.svg", # output
2.0, # nibsize (line size in output svg)
"#2200aa", # line color
0.32, # scaling factor
200, 146, 110, 56, # levels
2, # type
540,1021,0.7 # signature transform
)
Using the CLI:
blackstripes crossed ali.png --output ali_sketchy.svg
from blackstripes import spiral
spiral.draw("ali.png", # input
"ali_spiral.svg", # output
2.0 , # nibsize (line size in output svg)
"#aa0000", # line color
0.32, # scaling factor
180, 108, 180, 108, # levels
2, # linespacing
540,1021,0.7 # signature transform
)
Using the CLI:
blackstripes spiral ali.png --output ali_sketchy.svg
(This module is tested with python 2.7 and python 3.4 on mac-osx and linux, but it will probably work on most platforms.)
- Clone this repo
- navigate to the src folder
python setup.py build
python setup.py install
- navigate to the test folder
python sketchy-test.py
python crossed-test.py
python spiral-test.py