From f158d0b7447f328d7f135a7ea9e83d35509a14c2 Mon Sep 17 00:00:00 2001 From: Piotr Halama Date: Tue, 6 Aug 2024 20:19:00 +0200 Subject: [PATCH] fix photo view text position --- src/views/PhotoView.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/views/PhotoView.vue b/src/views/PhotoView.vue index d71ad35..8c101eb 100644 --- a/src/views/PhotoView.vue +++ b/src/views/PhotoView.vue @@ -46,10 +46,6 @@ const routeQuery = useRoute().query, } const ctx = mainCanvas.value.getContext('2d')!, runnerPosition = 208 + 101, - titleLength = ctx.measureText(title.value).width, - subtitleLength = ctx.measureText(subtitle.value).width, - titlesDiff = Math.abs(titleLength - subtitleLength), - titleMiddle = canvasWidth.value / 2, fullTitle = `${title.value} ${subtitle.value}` ctx.drawImage(imageGradient, 0, 0) @@ -93,7 +89,11 @@ const routeQuery = useRoute().query, ctx.font = `normal normal 600 ${titleFontSize.toString()}px Saira Condensed` } - const titleHeight = 442 + titleFontSize / 2 + const titleHeight = 442 + titleFontSize / 2, + titleLength = ctx.measureText(title.value).width, + subtitleLength = ctx.measureText(subtitle.value).width, + titlesDiff = Math.abs(titleLength - subtitleLength), + titleMiddle = canvasWidth.value / 2 let titlePosition = titleMiddle - titleLength / 2 + titlesDiff / 2, subtitlePosition = titleMiddle + subtitleLength / 2 + titlesDiff / 2