From 91205d8050bcc51fcfb399db007df12c02d9676c Mon Sep 17 00:00:00 2001 From: ztimson Date: Wed, 1 Jul 2026 19:36:14 -0400 Subject: [PATCH] Fixed ship guage --- client/src/components/Ship.vue | 51 +++++++++++++--------------------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/client/src/components/Ship.vue b/client/src/components/Ship.vue index f530b6d..f585b88 100644 --- a/client/src/components/Ship.vue +++ b/client/src/components/Ship.vue @@ -73,6 +73,7 @@ function onTouchEnd() { } onMounted(() => { + console.log(props.boat); document.addEventListener('mousemove', onMouseMove) document.addEventListener('mouseup', onMouseUp) document.addEventListener('touchmove', onTouchMove, { passive: false }) @@ -89,8 +90,7 @@ onUnmounted(() => { const compass = computed(() => { const hdg = heading.value - const course = props.boat.course ?? hdg - const bearing = props.boat.bearing ?? 0 + const course = props.boat.cog ?? hdg // ── Compass tape ────────────────────────────────────────────────────────── const tapeTicks: string[] = [] @@ -114,7 +114,7 @@ const compass = computed(() => { } // ── Rose centre & radii ─────────────────────────────────────────────────── - const CX = 100, CY = 158 // moved down from 145 + const CX = 100, CY = 140 // moved down from 145 const R = 68 // grown from 55 const rudder = Math.max(-30, Math.min(30, ((course - hdg + 540) % 360) - 180)) @@ -125,7 +125,7 @@ const compass = computed(() => { const cNeedleX = CX + 52 * Math.sin(courseRad) const cNeedleY = CY - 52 * Math.cos(courseRad) - const bearRel = ((bearing - hdg + 540) % 360) - 180 + const bearRel = ((course - hdg + 540) % 360) - 180 const bearRad = bearRel * Math.PI / 180 const bNeedleX = CX + 52 * Math.sin(bearRad) const bNeedleY = CY - 52 * Math.cos(bearRad) @@ -151,49 +151,38 @@ const compass = computed(() => { return `${lbl}` }).join('') - // Legend & rudder bar shifted to bottom of taller SVG - const LEG_Y = 190 - return ` - - + ${tapeTicks.join('')} - - - ${String(Math.round(hdg)).padStart(3, '0')}° - - - + - ${ringTicks} - ${cardinals} - - - + + ${ringTicks} + ${cardinals} + - - + + + - - - - + + - - - COG - - BRG + + COG + + + BRG ` })