mistval / unofficial-jisho-api

Encapsulates the official Jisho.org API and also provides kanji, example, and stroke diagram search.
MIT License
139 stars 14 forks source link

Stroke order animation #4

Closed hisekai closed 6 years ago

hisekai commented 6 years ago

Firstly, thank you for the awesome api. I'm using it in my personal project. Secondly, I was wondering if it would be possible to get the stroke animation or should I just directly use the kanjiVG for that?

mistval commented 6 years ago

Hi, thanks for your feedback :)

It looks like Jisho.org uses Javascript in the browser to animate the SVG files from KanjiVG. So I could have this API return a URI for the SVG that Jisho uses, if that's what you want, but then you would have to write the code to animate it. I could try to reverse-engineer Jisho's animation code to generate gifs that look the same as what you see when you run the animation on the website, but due to the high amount of work that would be involved I don't realistically see myself ever having time to do that.

If you want gifs but you don't need them to look exactly like they do on Jisho.org, you are welcome to use the ones that I generated from KanjiVG data for one of my projects, those are here: https://github.com/mistval/kotoba/tree/master/resources/images/kanjianimations . Those were generated using Kanimaji: https://github.com/maurimo/kanimaji . I can certainly add URIs to those in this API if that would get you the results you are hoping for.

Would either of those options do what you're hoping for? 1: Return a URI to the SVG that Jisho.org animates. 2: Return a URI to the appropriate gif file from here: https://github.com/mistval/kotoba/tree/master/resources/images/kanjianimations

hisekai commented 6 years ago

Hi, Thank you so much for the detailed response. Either option sounds perfectly fine, so whichever would be less time consuming and more convenient for you.

mistval commented 6 years ago

Check out the new version 1.1 (https://www.npmjs.com/package/unofficial-jisho-api) I've added both to the result data: a strokeOrderSvgUri and a strokeOrderGifUri property. Usage is demonstrated in the updated README.md.

Please note that a strokeOrderGifUri will always be returned, but a gif file may not exist at that location for some rare kanji. Gifs are available for about ~6000 kanji.

Closing the issue, please feel free to reopen if you have any trouble :)

hisekai commented 6 years ago

Thank you! It works great.