Skip to content

Commit dfc0266

Browse files
committed
consts
1 parent d173072 commit dfc0266

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/frontend/components/TrackMap/TrackCanvas.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ const ENABLE_TURNS = false;
3838
// Throttle position updates to 2fps (500ms interval)
3939
const POSITION_UPDATE_INTERVAL = 500;
4040

41+
const TRACK_DRAWING_WIDTH = 1920;
42+
const TRACK_DRAWING_HEIGHT = 1080;
43+
4144
export const TrackCanvas = ({ trackId, drivers }: TrackProps) => {
4245
const [positions, setPositions] = useState<
4346
Record<number, TrackDriver & { position: { x: number; y: number } }>
@@ -242,13 +245,13 @@ export const TrackCanvas = ({ trackId, drivers }: TrackProps) => {
242245
ctx.clearRect(0, 0, rect.width, rect.height);
243246

244247
// Calculate scale to fit the 1920x1080 track into the current canvas size
245-
const scaleX = rect.width / 1920;
246-
const scaleY = rect.height / 1080;
248+
const scaleX = rect.width / TRACK_DRAWING_WIDTH;
249+
const scaleY = rect.height / TRACK_DRAWING_HEIGHT;
247250
const scale = Math.min(scaleX, scaleY); // Maintain aspect ratio
248251

249252
// Calculate centering offset
250-
const offsetX = (rect.width - 1920 * scale) / 2;
251-
const offsetY = (rect.height - 1080 * scale) / 2;
253+
const offsetX = (rect.width - TRACK_DRAWING_WIDTH * scale) / 2;
254+
const offsetY = (rect.height - TRACK_DRAWING_HEIGHT * scale) / 2;
252255

253256
// Save context state
254257
ctx.save();

0 commit comments

Comments
 (0)