我有一個腳本,它在畫布上繪製圖像並允許人們在該圖像上繪製線條。我想從腳本的其他地方獲取上下文(即具有各種jQuery函數的頭文件)。這可能嗎?從腳本的其他位置獲取畫布上下文
我的意思是這樣的:
頁眉:
saveInfo = function()
{
//save all the inputs
//get the context of the canvas so we can find some properties
}
clearInfo = function()
{
//clear the inputs
//get the context of the canvas so we can clear it and redraw the main image
}
包含的文件
<script type="text/javascript">
//this is the script that produces the drawing functionality initially that I already have
</script>
編輯:我知道這似乎是顯而易見的,從而美化,每當有人繪製一條線在包含腳本的畫布中,我將其添加到名爲paths的json數組中。我需要能夠在保存部分得到這個。
您的網頁上有多少幅畫布?他們有唯一的ID嗎?輸入是否與特定的畫布相關聯? – Phrogz 2011-04-04 15:05:32