feat: snake color now changes dynamically based on position
This commit is contained in:
parent
1324f424e4
commit
68527227eb
@ -113,14 +113,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
|
||||
function draw() {
|
||||
const accentColor = getComputedStyle(document.body).getPropertyValue('--accent-color').trim();
|
||||
const canvasBg = getComputedStyle(document.body).getPropertyValue('--canvas-bg').trim();
|
||||
|
||||
ctx.fillStyle = canvasBg;
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
snake.forEach((segment, index) => {
|
||||
ctx.fillStyle = accentColor;
|
||||
const hue = (segment.x * 5 + segment.y * 5) % 360;
|
||||
ctx.fillStyle = `hsl(${hue}, 100%, 50%)`;
|
||||
if (index === 0) {
|
||||
ctx.fillRect(segment.x * gridSize, segment.y * gridSize, gridSize, gridSize);
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user