parsimonhi / animCJK

Draw animated Japanese characters (Kanji and Kana), Korean characters (Hanja) and Chinese characters (Hanzi) in correct stroke order using svg, free open-source code.
284 stars 72 forks source link

How to generate the graphicsKana.txt ? #17

Closed baihongjian closed 2 years ago

baihongjian commented 2 years ago

Hello,

How to generate the graphicsKana.txt file ? Just like the graphicsJa.txt file.

I want to make a function to identify Japanese kana.

Thank you for your reply !

parsimonhi commented 2 years ago

Hello,

Not an easy task!

I just added graphicsKana.txt to the project. However, with some kanas (あ お す な ぬ ね の は ほ ま み む め よ る ゐ ゑ ず ば ぼ ぱ ぽ ぁ ぉ ょ) there is a trick because they have an overlapping stroke on itself, and I have had to add some "ghost" medians to deal with this problem. Your function should ignore these "ghost" medians.

For example, in 12354.svg (which is the svg for "あ"), the median defined in the line containing clip-path = "url (# z12354c3b)" is a "ghost" median and should be ignored. So, in graphicsKana.txt, your function must skip the part corresponding to this median (to detect it, compare the numbers that define this median in graphicsKana.txt and in the svg file).

Generally speaking, when a median contains something like clip-path = "url (# znnnnncmx)" in an svg file, where n and m are numbers and x is a letter, keep the median when x is "a", and discard the others when x is "b", "c", ... (these are "ghost" medians).

Note that the shape of a stroke overlapping on itself is the sum of the paths that have id="znnnndmx" in the svg files.

Note that you cannot easily regenerate svg files from graphicsKana.txt when a kana has an overlapping stroke on itself. And that's the reason why I haven't included graphicsKana.txt in the project until now.

To simplify your function, it can be useful to precompute the medians to ignore and store this information elsewhere.

Don't hesitate to ask for additional details.

baihongjian commented 2 years ago

thank you very much ! I'll try it !