Workshop › Wolfenstein-style 3D Maze › Step 13 of 18
Every wall is the same gray, so corners vanish. Each kind of wall gets its own color; walls hit on their top or bottom face are darker, and everything fades with distance. That's enough to make the maze look solid.
```js
const COLORS = { '#': [148, 163, 184], 2: [185, 90, 60], E: [34, 197, 94] }
function shade(hit, dist) {
// Walls facing north or south are a little darker, and everything fades with distance.
const light = (hit.side === 'y' ? 0.7 : 1) * Math.max(0.25, 1 - dist / 12)
const [r, g, b] = COLORS[hit.tile]
return 'rgb(' + Math.round(r * light) + ', ' + Math.round(g * light) + ', ' + Math.round(b * light) + ')'
}
ctx.fillStyle = shade(hit, dist)
```COLORS gives each wall kind its red, green and blue.light is 1 for a near wall hit on its side face; 0.7 times that on its top or bottom face; it drops with distance
but never below 0.25.'rgb(105, 115, 130)'.FOV, write COLORS.draw, write shade.shade(hit, dist) as the color.Skills: Drawing on a canvas