Search notes:

HTML element: canvas

Draw graphics onto a HTML page with JavaScript.
There are two APIs with which graphics can be rendered onto a <canvas> element:

getContext()

<!doctype html>
<html>
<head>

    <script type="text/javascript">

       function main() {
           let cnv = document.getElementById('cnv');
           let gl  = cnv.getContext('webgl2');

        //
        // Type (interface) of gl is WebGL2RenderingContext
           console.log(gl.constructor);
       }

    </script>

</head>

<body onload="main()">

  <canvas id='cnv'>
    Canvas is not supported.
  </canvas>

</body>
</html>
Github repository about-HTML, path: /tags/canvas/getContext-webgl2.html

See also

Code snippets related to the <canvas> element.
The HTMLCanvasElement object.
text related, such as fillText to write text onto a canvas.
performance tests
HTML elements

Index