1

In Java, how can I read in the d attribute of an SVG path, and discretize it such that all Bezier curves are properly subdivided into discrete points, allowing me to specify a threshold to account for sharp angles?

The only solution I've found after a ton of searching is to use Apache Batik to traverse the path in short intervals, and sample points uniformly, but that generates a bunch of unnecessary points along straight lines and doesn't handle the case of sharp angles.

Brandon
  • 1,336
  • 3
  • 10
  • 38

1 Answers1

0

I implemented an algorithm to convert a quadratic bezier into a set of straight lines (vertices) in Javascript a while back. Its here in action

It's not Java but it should not be too hard to convert, You should filter out the bezier curves yourself by regexing on [Q,q,C,c,S,s]

Some discription is here.

Community
  • 1
  • 1
dr jerry
  • 9,768
  • 24
  • 79
  • 122