I have a script that draws an image on a canvas and allows people to draw lines on this image. I want to get the context from elsewhere in the script (i.e. a header that has various jQuery functions). Is this possible?
What I mean is something like:
Header:
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
}
Included File
<script type="text/javascript">
//this is the script that produces the drawing functionality initially that I already have
</script>
Edit: I realise this may seem obvious so to embellish, whenever someone draws a line on the canvas in the included script I add to a json array called paths. I need to be able to get this in the save section.
… will work in any place in your script.