

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is getContext in HTML5 Canvas?
The canvas element has a DOM method called getContext, used to obtain the rendering context and its drawing functions. This function takes one parameter, the type of context 2d.
Following is the code to get required context along with a check if your browser supports <canvas> element:
var canvas = document.getElementById("mycanvas"); if (canvas.getContext){ var ctx = canvas.getContext('2d'); // drawing code here } else { // canvas-unsupported code here }
- Related Questions & Answers
- What is composition in HTML5 Canvas?
- Can we delete the “getContext” property of HTML5 Canvas tag through script?
- What is a transformation matrix in HTML5 canvas?
- What is the difference between SVG and HTML5 Canvas?
- Translating HTML5 canvas
- HTML5 Canvas distorted
- HTML5 Canvas Transformation
- What are free libraries for Canvas in HTML5?
- HTML5 Canvas Transformation Matrix
- HTML5 Canvas Circle Text
- HTML5 Canvas Degree Symbol
- Composition attribute in HTML5 Canvas?
- Is HTML5 canvas and image on polygon possible?
- What are save and restore methods in HTML5 Canvas?
- HTML5 Canvas Font Size Based on Canvas Size
Advertisements