且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用javascript从图像创建拼图

更新时间:2023-11-20 15:11:40

这个拼图有几个部分。 :)



第一部分是SVG及其Canvas。这就是你需要画出来的,因为否则你不能做出一个弯曲的图片。使用标准HTML / CSS只能使用矩形。



第二部分是从图片中生成拼图的算法。如果你不能自己弄明白(虽然看起来不复杂),Google应该帮助你。



其他应该很简单。 p>

已添加:快速 Google搜索在第一个结果中提供了这样的拼图引擎。请查看其来源


I googled it but didn't find a good answer. Specifically, I want to learn:

  • to slice an image into curved pieces
  • to create individual objects from those pieces (i assume that i need this to reassemble)

thanks.

There are several pieces to this puzzle. :)

The first piece is SVG and its Canvas. That's what you'll need to draw, because otherwise you can't make a curved piece out of a picture. Only rectangles are possible with standard HTML/CSS.

The second piece is an algorithm for generating jigsaw pieces from the picture. Google should help you with that if you can't figure one out by yourself (though it doesn't seem very complicated).

The rest should be straightforward.

Added: A quick Google search gave just such a jigsaw engine in the first result. Check out the source of that.