Getting values from HTML5 Canvas to JavaScript

HTMLWeb DevelopmentFront End Technology

When we draw anything on Canvas, it keeps no memory of anything that was drawn. While drawing we need to keep track of all the necessary information yourself as we draw. Therefore, it is not feasible to get value from HTML5 canvas to JavaScript as it keeps no memory. It just draws like this −

<canvas id = "myCanvas" height = "300" width = "500" style = "border:2px solid #808080;"></canvas>

On adding a function for button and clicking on it, you won’t be able to get what you want −

<div>
   <input type = "button" value = "Submit" onclick = "submit()">
</div>

You will not be able to get those values from the canvas since the canvas is just a bitmap.

raja
Published on 21-Mar-2018 08:09:49
Advertisements