Time for action – creating an HTML5 canvas

  1. Using your favorite editor, create a web page with the following code in it:
    <!DOCTYPE html>
    <html>
    <head>
       <title> WebGL Beginner's Guide - Setting up the canvas </title>
       <style type="text/css">
       canvas {border: 2px dotted blue;}
       </style>
    </head>
    <body>
    <canvas id="canvas-element-id" width="800" height="600">
    Your browser does not support HTML5
    </canvas>
    </body>
    </html> 

    Tip

    Downloading the example code

    You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

  2. Save the file as ch1_Canvas.html.
  3. Open it ...

Get WebGL Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.