Secondary Canvas drawing and secondary canvas drawing
For Canvas plotting, you can use the toDataURL () method to save the drawn image, and then provide it to the object element for secondary use.
<P> Canvas plotting </p> <canvas id = "mycanvas" width = "300" height = "150"> </canvas> <p> restore plotting </p> <object type = "image/png" id = "myimage"> </object>
Js Processing
<Script type = "text/javascript"> var canvas = document. getElementById ("mycanvas"); if (canvas & canvas. getContext) {var cxt = canvas. getContext ('2d '); cxt. fillStyle = "# FF0000"; cxt. fillRect (,);} var url = canvas. toDataURL (); // return the base64 encoded data of the image. You can also upload a MIME-Type format, such as image/png var img = document. getElementById ("myimage"); img. data = url; // restore the image. MIME is specified. You can also use the src attribute. </script>
Result: