SVG: simplify path to remove curves?

浪尽此生 提交于 2019-12-04 18:09:44

问题


I have a svg file which contains complex paths with bezier curves in it. I need to convert this path-data to use it for html map-area's, so I in fact I need just the coordinates (but for large curves, it would be very nice to have some coordinates 'between' the two end-points.

I tried Inkscape's simplify path function, but those paths still contain curves...

Is there any tool or formula to convert these curves into simple coordinates?

Maybe another Inkscape output-format that doesn't use curves in its coordinates?


回答1:


In Inkscape:

  • Select the Edit Path By Nodes tool (F2).
  • Click on your path to select it
  • Ctrl-A to select all the nodes in that path
  • Click Make Selected Segments Lines (on the toolbar at the top - the icon is a straight diagonal line between two square nodes).



回答2:


For automation, try the included Flatten Bezier extension in Inkscape. Description here.




回答3:


There is more technical way to simplify SVG path - https://github.com/mattdesl/simplify-path

var path = [ [250, 150], [250, 150], [25, 25], [24, 25], [10, 10] ]
var tolerance = 10
path = simplify(path, tolerance)
//result:
//[ [ 250, 150 ], [ 25, 25 ], [ 10, 10 ] ]


来源:https://stackoverflow.com/questions/6386786/svg-simplify-path-to-remove-curves

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!