最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Bitmap to svg path - Stack Overflow

programmeradmin1浏览0评论

I don't know how to make this algorithm in JavaScript/Node.js that converts bitmaps into svg paths pixel by pixel:

// input
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 
0 0 1 1 1 1 1 1 0 0 
0 0 1 1 1 1 1 1 0 0 
0 1 1 1 0 0 1 1 1 0 
0 1 1 1 0 0 1 1 1 0 
0 0 1 1 1 1 1 1 0 0 
0 0 1 1 1 1 1 1 0 0 
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 

// output
<path d="M2 2 h6 v2 h1 v2 h-1 v2 h-6 v-2 h-1 v-2 h1 v-2 M4 4 v2 h2 v-2 z">

Does anyone know how the algorithm should work?

Any pseudocode would help.

Tools does the similar approach:

  • .html

I don't know how to make this algorithm in JavaScript/Node.js that converts bitmaps into svg paths pixel by pixel:

// input
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 
0 0 1 1 1 1 1 1 0 0 
0 0 1 1 1 1 1 1 0 0 
0 1 1 1 0 0 1 1 1 0 
0 1 1 1 0 0 1 1 1 0 
0 0 1 1 1 1 1 1 0 0 
0 0 1 1 1 1 1 1 0 0 
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 

// output
<path d="M2 2 h6 v2 h1 v2 h-1 v2 h-6 v-2 h-1 v-2 h1 v-2 M4 4 v2 h2 v-2 z">

Does anyone know how the algorithm should work?

Any pseudocode would help.

Tools does the similar approach:

  • https://github./59naga/pixel-to-svg
  • https://github./brainshave/sharpvg
  • https://codepen.io/shshaw/pen/XbxvNj
  • http://drububu./tutorial/bitmap-to-vector.html
Share Improve this question edited Mar 5, 2017 at 9:00 defghi1977 5,3692 gold badges32 silver badges31 bronze badges asked Mar 4, 2017 at 11:18 pravdomilpravdomil 2,9691 gold badge25 silver badges38 bronze badges 2
  • 1 So Your question is "I'm creating an algorithm. I don't know how to make this algorithm"? – Mike B Commented Mar 4, 2017 at 11:23
  • yes, I will update the question – pravdomil Commented Mar 4, 2017 at 11:24
Add a ment  | 

1 Answer 1

Reset to default 9

You can converts pixels to SVG path string like this.

Using this algorithm, I made script coverts pixel art to SVG.

http://defghi1977.html.xdomain.jp/tech/img2svg3/dot2svg3.htm

(Sorry this page is written in Japanese.)

发布评论

评论列表(0)

  1. 暂无评论