Coder Social home page Coder Social logo

Comments (6)

skishore avatar skishore commented on September 26, 2024

It seems that you've already separated your character into strokes - at least, that path you linked looks like a single stroke. Is that right? If so, please take a look at:

https://github.com/skishore/makemeahanzi/blob/tool/lib/median_util.js

In that file, findStrokeMedian takes an SVG path and returns an approximate median (with many points on it), and normalizeForMatch uses the simplify library to reduce that median to an a further approximation with fewer points. I hope that helps!

The tool code isn't licensed yet, mainly because I don't think it's in a great state to be used by other people, but at least those libraries are decent. If you find that that code works for your case then I'll add an MIT license.

from makemeahanzi.

TomClarkson avatar TomClarkson commented on September 26, 2024

Thanks very much for your reply. I extracted the findStrokeMedian code and it perfectly with the data above. However, I was hoping to use some hirigana stroke data so I could use it with hanzi-writer but the path data for hirigana strokes has c commands in the path data which isn't accepted.

screen shot 2017-06-16 at 9 27 26 am

Is there any way I could get hirigana stroke data in the makemeahanzi format?

https://github.com/TomClarkson/makemeahanzidata/blob/master/src/index.js#L26

from makemeahanzi.

skishore avatar skishore commented on September 26, 2024

I've written some hacks that are partially working for rendering the cubic elements. They're not at a level at which I'd want to commit them to the branch itself, but they may be usable for your case. Be warned that most methods in svg.js still don't handle cubics well; I just got convertSVGPathToPaths and computePolygonApproximation sort of working:
https://github.com/skishore/makemeahanzi/commits/cubic

However, that path that you linked doesn't seem to be a proper stroke. It doesn't loop back on itself, for starters: https://codepen.io/anon/pen/eRBKoN Where did you get that data from?

from makemeahanzi.

TomClarkson avatar TomClarkson commented on September 26, 2024

Hi I got the stroke data from kanjivg I thought if I could get the stroke from the one character to work then I could use hirigana and katakana data from KanjiVG. Here is the data for the one character https://github.com/KanjiVG/kanjivg/blob/master/kanji/04e00.svg. I guess the data is too different to be used because KanjiVG data is just straight lines. (Sorry I don't know much about SVG).

Could the hirigana data be extracted from the Arphic font? I'm not sure how to do this. If not or it is difficult please close this issue. Thanks again.

from makemeahanzi.

skishore avatar skishore commented on September 26, 2024

Gotcha. The Arphic font only contains hanzi/kanji, so no hiragana there. However, the KanjiVG data is basically already in the "median" form - the strokes that the provide are lines, not outlines.

Basically, for the KanjiVG data, if you take those changes I made, comment out the "Path has open contour" assertion (which only applies to outlined strokes), and then call "GetPolygonApproximation", you'll have a median already.

from makemeahanzi.

TomClarkson avatar TomClarkson commented on September 26, 2024

I'm not sure to call them GetPolygonApproximation from sorry, it is over my head.

https://github.com/TomClarkson/makemeahanzidata/blob/master/src/makemeahanzi/svg.js#L91

from makemeahanzi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.