Toggle navigation
☰
HTML
CSS
Scripting
Database
<!DOCTYPE html> <html> <body> <canvas id="colorCanvas" width="300" height="150" style="border:1px solid #d3d3d3;"></canvas> <script> var canvas = document.getElementById("colorCanvas"); var ctx = canvas.getContext("2d"); // Setting fillStyle to a CSS color string ctx.fillStyle = "rgba(0, 112, 192, 1)"; ctx.fillRect(20, 20, 100, 100); // Setting globalAlpha for transparency ctx.globalAlpha = 0.5; ctx.fillStyle = "#FF8C00"; ctx.fillRect(80, 40, 100, 100); // Using a transparent color directly ctx.fillStyle = "rgba(0, 0, 0, 0.3)"; ctx.fillRect(140, 60, 100, 100); </script> </body> </html>