0.5 AGPL v3    
  not rated
A script and module to create colored stroke order diagrams based on KanjiVG data




KanjiColorizer is a Python script for coloring, resizing, and renaming the stroke order diagrams from the KanjiVG project.

Developer comments

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.

Getting diagrams

If you just want some colorted diagrams, you can get them at Downloads.

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.)

Generating diagrams

If you download and run this script, as well as the choice between spectrum or contrast available in the downloadable sets of diagrams, you can choose other options such as the saturation and value of the colors.


1. Make sure you have python 2.7 installed. Mac and and most Linux distros come with this included so only Windows users need this step.
2. Run python kanji_colorize.py. python kanji_colorize.py --help will list available options so you can customize the results. If you want to save a set of options, you can create a shell script.
3. You will find your diagrams in the colorized-kanji directory or the output directory you chose.

If you want to try out your settings without spending the time processing the whole kanji collection, use test/kanjivg/kanji for the input directory. It contains just four svgs.

Using with Anki

To add these to a kanji deck:

1. Unzip the downloaded collection if you downloaded it
2. Put the contents in your deck's .media folder (which is most likely in your Dropbox/Public/Anki folder if you sync media or next to your deck at [My ]Documents/Anki if you don't.) If your deck doesn't have a media folder create a directory with the same name as your deck except ending in .media instead of .anki.
3. Add < img src={{text:Kanji}}.svg > to your card template, where Kanji is the name of a field that contains a single kanji character. Note that {{text:Kanji}} (or {{Kanji}}) can't be used in the same template as {{{Kanji}}}; see Anki's CardLayout help page for more information.
4. Close and re-open your deck.

Now all kanji cards you have and all the ones you add will get stroke order diagrams without any more work from you.


 If you aren't going to be adding any more kanji to your deck and you'd like to delete all the extra files, you can run "Tools >> Advanced >> Check Media Database..." and select "scan and delete". If you do this and want to add more kanji later, you will have to repeat the above steps again.

There are examples of the diagrams and more on using stroke order diagrams with anki in this Japanese Level Up post.
Last updated on May 28th, 2012

0 User reviews so far.