globalAlpha

by aio350

HTML

<canvas width="300" height="300" style="border: 1px dotted #222"></canvas>

CSS

body {
  margin: 0;
  height: 100vh;
  background: radial-gradient(circle, skyblue, steelblue);
  display: flex;
  justify-content: center;
  align-items: center;
}

JavaScript

const canvas = document.querySelector('canvas')
const $ = canvas.getContext('2d')

$.fillStyle = '#fd0'
$.fillRect(0, 0, 150, 150)
$.fillStyle = '#6c0'
$.fillRect(150, 0, 150, 150)
$.fillStyle = '#09f'
$.fillRect(0, 150, 150, 150)
$.fillStyle = '#f30'
$.fillRect(150, 150, 150, 150)
$.fillStyle = '#fff'
$.globalAlpha = .2

for (let i = 0; i < 7; i++) {
  $.beginPath()
  $.arc(150, 150, 40 + 20 * i, 0, Math.PI * 2)
  $.fill()
}