Home > Blockchain >  About inkscape usage of H and V path command
About inkscape usage of H and V path command

Time:07-03

I’m trying to do generate sketchy svg file by vectorizing pics. Thenafter, I rework the svg with some node script.

To achieve my goal, I have to determine if a point is over a given path. To do that I use https://github.com/rubenv/point-in-svg-polygon

When I call isInside(point, path), I encounter an error: Uncaught Error Error: Unknown operator: for polygon

After debugging, I can see that my SVG contains V and H commands with 2 parameters, and the lib restricts to one.

Exemple

<path d="M 0,512 V 0 H 512 1024 V 512 1024 H 719.62244 C 450.28457,1024 ... Z" id="path2785"/>

The documentation tends to agree with the lib according to https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths, but I can’t imagine Inskape doing this for no reason.

Could you tell me why inkscape is doing this (can’t find it with google) ? Is this an issue of the library or with inkscape?

CodePudding user response:

All path commands that take values can have those values repeated and they generally mean repeat that command.

per the specification, M 0,0 H 5 10 means the same as M 0,0 H 5 H 10

The only exception is M, which turns into L (and m which becomes l) so

M 0,0 10,0 means M 0,0 L 10, 0

This isn't that useful for H and V because it won't look much different unless you're drawing markers. For example if you draw a horizonal line from 0,0 to 10,0 that will look the same usually as drawing a horizontal line from 0,0 to 5,0 and then continuing that line from 5,0 to 10,0.

  • Related