Example 1 — Quick demo
Core Canvas.
JavaScript
console.log("const ctx = canvas.getContext('2d');");
console.log("ctx.fillRect(0, 0, 10, 10);");How It Works
- getContext. Obtain a drawing context.
- fillRect. Draw a rectangle.
The Canvas API draws 2D (or WebGL) graphics via <canvas> and getContext('2d').
| Topic | Summary |
|---|---|
basics | core Canvas usage. |
console.log("const ctx = canvas.getContext('2d');");
console.log("ctx.fillRect(0, 0, 10, 10);");Core Canvas.
console.log("const ctx = canvas.getContext('2d');");
console.log("ctx.fillRect(0, 0, 10, 10);");CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
6 people found this page helpful