function draw() {
const canvas = document.querySelector('#test')
const ctx = canvas.getContext('2d')
// ctx.fillStyle = 'rgb(200, 0, 0)'
ctx.fillRect(10, 10, 50, 50)
ctx.fillStyle = 'rgba(0,200,0, 0.5)'
ctx.fillRect(20, 20, 50, 50)
ctx.fillStyle = 'rgb(0,0,200)'
ctx.strokeRect(30, 30, 50, 50)
}
draw()
<canvas id='test' width="150" height="150"></canvas>
canvas{
border: 1px solid black
}