最简单的“绘制"方式用jQuery在图像上的简单线条并保存到Rails DB? [英] Easiest way to "draw" simple lines over an image with jQuery and save to Rails DB?
问题描述
我想在图像上画线.基本上允许用户为自己喜欢的山路绘制路径.
I'd like to draw lines on an image. Basically allow the user to draw a path for mountain trails they like.
1)有人知道一个简单的绘制基本线条的简单库吗?
1) Does anyone know a good simple library for drawing basic lines?
2)用户在图像上绘制一束线后,将数据保存到数据库的最佳方法是什么?
2) After a user draws a bunch of lines on an image, what would be the best way to save the data to the database?
推荐答案
画线
- Paper.js .查看路径简化示例.
- 拉斐尔- Raphael SketchPad
- Paper.js . Look at the Path Simplification example.
- Raphaël - Raphael SketchPad
Drawing lines
您可以轻松地将元素叠加在图像上方,以便用户在图像上进行绘制.
You can easily overlay the elements on top of an image so the user draws on the image.
也,只是为了好玩,但你见过吗 SVG编辑(
Also, just for fun, but have you seen SVG-edit (demo)?
上面的SketchPad脚本以JSON提供了绘制的数据,这些数据可以以纯文本格式保存在数据库中.可以对PaperJS的对象执行相同的操作.这是带有PaperJS的JSFiddle 示例(此处以图片为背景.
The SketchPad script above provided drawn data in JSON that can be saved as plain text in the database. The same thing can be done on the objects from PaperJS. Here is a JSFiddle example with PaperJS (code) and here with an image as a background.
这篇关于最简单的“绘制"方式用jQuery在图像上的简单线条并保存到Rails DB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!