JSFiddle - React, Tailwind, and code Playground

by artwl

HTML

<canvas id="myCanvas" width="440" height="300">
    您的浏览器不支持canvas!
</canvas>

CSS

canvas{
    border:1px solid #CCC;
}

JavaScript

var canvas = document.getElementById("myCanvas");
if (!canvas.getContext) {
    return;
}

var ctx = canvas.getContext("2d");

ctx.save();

ctx.shadowOffsetX = 10;
ctx.shadowOffsetY = 10;
ctx.shadowBlur = 5;
ctx.shadowColor = "rgba(0, 0, 0, 0.5)";

ctx.fillStyle = "#CC0000";
ctx.fillRect(10, 10, 150, 150);

ctx.restore();

ctx.fillStyle = "#000000";
ctx.fillRect(180, 10, 150, 100);