我试图实现一个html5绘图应用程序。目前,我可以允许绘制的图像被保存。我想能够有一个重新绘制图像的重播功能相同它的原始绘制方式几乎就像是一个视频任何想法?HTML5 drawing with“replay”feature“
1
A
回答
1
画布没有DOM树,因为joni的建议。画布绘制像素,所以在绘制完成后无法检索或移动单个对象
您可以使用canvas.getImageData()将数组保存到一个数组,然后使用canvas.putImageData()以相同的顺序恢复这些数据框虽然我不确定它是如何执行的大帆布尺寸。
样品:
// Start with an array where you'll save all frames.
var frames = [];
// Save the output of your canvas to the frames array. Do this every X seconds or X amount of drawing.
var frame = myCanvasElement.getImageData(0, 0, myCanvasElement.width, myCanvasElement.height);
frames.push(frame);
// When the user is done drawing, you can do a replay by restoring the frames one by one in a certain interval.
var fps = 15;
var i = 0;
var myInterval = setInterval(function()
{
myCanvasElement.putImageData(frames[i], 0, 0);
i++;
if (i == frames.length)
{
// We've played all frames.
clearInterval(myInterval);
}
}, 1000/fps);
+0
那么你有什么想法,我应该用这个? – 2010-10-26 02:11:21
+0
我添加了一个样本,可以帮助您了解这个想法。您必须调整它以使其适合您的情况。 – Blaise 2010-10-26 19:36:31
1
相关问题
- 1. Feature-Toggle with GWTP
- 2. Multiselect combobox with typeahead feature
- 3. Freeform Drawing with Android Maps v2
- 4. Segfault with large feature vector LibSVM
- 5. angular $ routeProvider with html5
- 6. Canvas Complete Drawing
- 7. Angular2 Observables - Replay
- 8. smartgwt drawing
- 9. Java Swing Die drawing
- 10. drawing NSImage tiles
- 11. GraphicsExtension for Drawing?
- 12. HTML5 Summary/Details with a table
- 13. Zend Form W3C validation with HTML5 Doctype
- 14. HTML5 Video with Video.js和AJAX
- 15. Viewgroup not drawing its children
- 16. Rebase/Replay仅合并提交
- 17. Replay tic tac toe游戏
- 18. Java OpenGL Cube Not Drawing
- 19. Core Graphics drawing only only
- 20. Android:canvas drawing,drawARGB和drawColor
- 21. On Image Drawing保存
- 22. CAKEPHP ORM Feature
- 23. ldap memberOf Feature
- 24. Plone Feature查询
- 25. Feature Vector Partioning
- 26. Wordpress Post Feature Clone
- 27. Parent uses-feature android.hardware.location
- 28. playn with HTML5中的JSON问题
- 29. HTML5 FileApi + FileReader - Feed <object> with SWF
- 30. Google maps javascript drawing a polyline
如果这些元素按照它们的绘制顺序存储在画布中,难道你不能沿着画布内的DOM树走下去,并在两者之间使用定时器/睡眠? – joni 2010-10-25 15:43:32