diff --git a/functions/src/cover.js b/functions/src/cover.js index a297f58..5c927f1 100644 --- a/functions/src/cover.js +++ b/functions/src/cover.js @@ -16,6 +16,7 @@ const { sendNotification } = require('./notifications') const bucket = admin.storage().bucket() const BRAND_TEXT = 'By Musicland.ai' const BRAND_FONT_FAMILY = 'Poppins, Montserrat, Arial, sans-serif' +const BRAND_BG_COLOR = 'rgba(0,0,0,0.65)' const escapeSvgText = (value = '') => String(value).replace(/&/g, '&').replace(//g, '>') @@ -29,7 +30,20 @@ const buildBrandSvg = ({ width = 1024, height = 1024, text = BRAND_TEXT } = {}) const strokeWidth = Math.max(2, Math.round(fontSize * 0.08)) const shadowDy = Math.max(2, Math.round(fontSize * 0.08)) const shadowBlur = Math.max(4, Math.round(fontSize * 0.18)) + const paddingX = Math.max(10, Math.round(fontSize * 0.7)) + const paddingY = Math.max(6, Math.round(fontSize * 0.4)) + const approxCharWidth = fontSize * 0.62 const safeText = escapeSvgText(text) + const textLength = safeText.length + const textWidth = + approxCharWidth * textLength + letterSpacing * Math.max(0, textLength - 1) + const rectWidth = Math.max(0, Math.round(textWidth + paddingX * 2)) + const rectHeight = Math.round(fontSize + paddingY * 2) + const rectX = Math.max(0, Math.round(safeWidth - margin - rectWidth)) + const rectY = Math.max(0, Math.round(safeHeight - margin - rectHeight)) + const textX = rectX + rectWidth / 2 + const textY = rectY + rectHeight / 2 + const rectRadius = Math.max(6, Math.round(rectHeight * 0.35)) return Buffer.from(` @@ -38,11 +52,20 @@ const buildBrandSvg = ({ width = 1024, height = 1024, text = BRAND_TEXT } = {}) +