2
캔버스에 50px x 50px의 고정 크기로 다른 색상의 사각형을 그립니다.색이있는 사각형에 반투명의 내부 획을 생성 하시겠습니까?
나는이 컬러 스퀘어에 5px의 투명한 내부 스트로크를 성공적으로 추가했지만, 내가하고있는 것처럼 과도한 잔인한 느낌이 들었습니다.
ctx.fillStyle = this.color;
ctx.fillRect(this.x, this.y, engine.cellSize, engine.cellSize);
ctx.fillStyle = 'rgba(0, 0, 0, 0.2)';
ctx.fillRect(this.x, this.y, engine.cellSize, engine.cellSize);
ctx.fillStyle = this.color;
ctx.fillRect(this.x + 5, this.y + 5, engine.cellSize - 10, engine.cellSize - 10);
3 개의 직사각형을 그리는 것보다 나은 방법이 있습니까?