我試圖實現一個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