kanji-colorize icon indicating copy to clipboard operation
kanji-colorize copied to clipboard

Add option to draw grid under characters

Open teozec opened this issue 3 years ago • 1 comments

Hi! I tried to implement a feature that I think could be useful: an option to draw a grid under the character.

At first, I added the setting "grid" to the _parser. The options are:

  • "none": no grid (the default)
  • "4": a 2x2 grid
  • "8": a 4x4 grid
  • "diag": a diagonal grid
  • "diag4": a 2x2 grid with diagonals
  • "diag8": a 4x4 grid with diagonals

I am not very creative: if you have better ideas for the names of the options let me know.

Then I added a function _add_grid (only called if grid is not "none") which adds to the svg a group <g id="kvg:grid" stroke="grey"> containing the needed paths in it. If you wish to change the id or the color, please let me know.

The tests I have written pass, and I modified the default_results files to reflect the fact that the "grid" option is added to the svg copyright notice so that also previous tests are ok (except one that was also failing before the changes).

Finally, I have also added the option to the Anki add-on, defaulting to "none".

I have attached an example of the generated images. Let me know if you think I should add or change anything!

teozec avatar Apr 16 '21 15:04 teozec

Thanks, this is really nice. I'll take a closer look when I have time.

cayennes avatar Apr 20 '21 22:04 cayennes

I merged this on the cli.

cayennes avatar Jul 03 '24 19:07 cayennes