kanji_colorize.py
is a script for coloring, resizing, and renaming the stroke order diagrams from the KanjiVG project. I wrote it to create sets that make it possibe to easily add stroke order diagrams to an anki kanji deck, but they can be used for anything you want some nicely colored stroke order diagrams for.
If you'd prefer not to bother running a python script, there are some sets of stroke order diagrams generated with it available for download.
If you just want some colorted diagrams, you can get them at Downloads. (Unfortunately github downloadable custom packages have been depricated so I will not be able to update these.)
I've packaged up a spectrum set and a contrast set. The spectrum set colors the strokes in rainbow order and is nice because the you can see at a glance how the kanji is put together, but has the disadvantage that stokes next to each other are similar colors, and color is sometimes necessary to tell which number goes with which stroke. The contrast set maximizes the contrast between any set of consecutive strokes. (This uses the golden ratio. Math is nifty.)
If you want the command line script to generate diagrams to your own specifications, such as saturation and value as well as the choice between spectrum and contrast, the easiest way to install it is:
- Make sure you have python 2.7 installed.
- Run the command
pip install KanjiColorizer
The script should now be available by running kanji_colorize.py
. You can supply it with the --help
option to see what's available.
There is an addon for Anki2 that generates colored diagrams for all of your kanji cards. You can download it from the Anki2 Addon site.
While I originally had instructions for a way to use a set of generated diagrams with Anki1, it never worked very well.
The code is designed to be imported and used in python programs, but the API will be changing.
Documentation can be found in the docstrings. Though I have to admit that I used doctest, which mean writing not-great documentation and not-great tests for almost no work.
If there's anything you think would improve these, you can use the issue tracker or email me at cayennes@gmail.com.
If you find any errors in image files generated by the most recent version of kanji colorizer, check to see whether they have been fixed in the KanjiVG data by looking at their online kanji viewer. If it is correct there, it means that I didn't notice that there was an update; let me know and I'll fix it. If the error exists there, let the KanjiVG project know using their issue tracker.
Have you created an improvement to KanjiColorizer that you think other people would also like to have? If so, please submit a patch or a pull request! I'm not always very prompt but I do get to them eventually.
Please make sure existing tests pass. Even better, add new tests for anything you add. Either doctest or unittest is fine, though ideally the doctests would contain executable examples that fully illustrate the function and the unittest tests would contain further worthwhile checks.
To run the existing tests:
$ python -m kanjicolorizer.colorizer $ python -m unittest discover
The code is available under the Affero GPL version 3 or later and the SVG images are available under Creative Commons Attribution-Share Alike 3.0. See file headers and files in licenses/
for more information.