Canvas element
The HTML canvas element allows for dynamic, scriptable rendering of 2D shapes and bitmap images. Introduced in HTML5, it is a low level, procedural model that updates a bitmap. The element also helps in making 2D games. While the element offers its own 2D drawing API, it also supports the WebGL API to allow 3D rendering with OpenGL ES. Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.
The HTML canvas element allows for dynamic, scriptable rendering of 2D shapes and bitmap images. Introduced in HTML5, it is a low level, procedural model that updates a bitmap. The element also helps in making 2D games. While the element offers its own 2D drawing API, it also supports the WebGL API to allow 3D rendering with OpenGL ES. This text is displayed if your browser does not support HTML canvas element. Using JavaScript, you can draw on the canvas: var example = document.getElementById('example'); var context = example.getContext('2d'); context.fillStyle = 'red'; context.fillRect(30, 30, 50, 50); This code draws a red rectangle on the screen. The Canvas API also provides save() and restore() , for saving and restoring all the canvas context's attributes. Canvas element size: 600 x 300, Canvas drawing surface size: 300 x 150 body { background: #dddddd; } #canvas { margin: 20px; padding: 20px; background: #ffffff; border: thin inset #aaaaaa; width: 600px; height: 300px; } Canvas not supported
Cite this
"Canvas element". 1775982409. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1348381325 JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy