snake: add catmull-rom rendering mode

This commit is contained in:
2026-08-15 15:44:59 +02:00
parent 3a58f98acf
commit db3aabc03e
3 changed files with 34 additions and 20 deletions
+1 -12
View File
@@ -3,17 +3,6 @@ export interface Point {
y: number;
}
export const DIRECTIONS: Point[] = [
{ x: 0, y: -1}, // N
{ x: -1, y: -1}, // NW
{ x: 1, y: -1}, // NE
{ x: -1, y: 0}, // W
{ x: 1, y: 0}, // E
{ x: 0, y: 1}, // S
{ x: -1, y: 1}, // SW
{ x: 1, y: 1}, // SE
];
export function lerpPoint(a: Point, b: Point, p: number) {
return {
x: a.x + (b.x - a.x) * p,
@@ -150,7 +139,7 @@ export function drawLine(ctx: CanvasRenderingContext2D, start: Point, end: Point
ctx.restore();
}
function rgbToString(color: number) {
export function rgbToString(color: number) {
return `#${color.toString(16).padStart(6, '0')}`;
}