Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
const ctx = canvas.getContext("2d"); // Draw a triangle ctx.beginPath(); ctx.moveTo(150, 20); // Starting point ctx.lineTo(280, 180); // Line to ctx.lineTo(20, 180); // Another line ctx.closePath(); // Close back to start ctx.fillStyle = "#ffc107"; ctx.fill(); ctx.strokeStyle = "#333"; ctx.lineWidth = 2; ctx.stroke();
Result
Open