From 9da02069c9ea66cbd495a197416f6d40632bedf2 Mon Sep 17 00:00:00 2001 From: SlayerOrnstein <6075693+SlayerOrnstein@users.noreply.github.com> Date: Thu, 2 May 2024 15:10:30 -0400 Subject: [PATCH] fix: remove extra padding around images --- src/drawers.ts | 4 ++-- src/generator.ts | 8 +++++++- tests/generator.spec.ts | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/drawers.ts b/src/drawers.ts index ff87471..c3ca7ca 100644 --- a/src/drawers.ts +++ b/src/drawers.ts @@ -100,7 +100,7 @@ export const drawText = ( context.textAlign = 'center'; context.textBaseline = 'middle'; - context.font = 'bold 14px "DroidSans"'; + context.font = '300 16px "OpenSans"'; context.fillStyle = textColor(tier); context.fillText(name, x, 280); @@ -161,7 +161,7 @@ export const drawBackground = async (mod: Mod, width: number, height: number, ra } const polarity = await drawPolarity(tier, mod.polarity); - context.drawImage(await loadImage(polarity), 230, 100, 18, 18); + context.drawImage(await loadImage(polarity), 230, 101, 16, 16); return canvas.encode('png'); }; diff --git a/src/generator.ts b/src/generator.ts index 6884cf7..5dec5d2 100644 --- a/src/generator.ts +++ b/src/generator.ts @@ -25,7 +25,13 @@ export const generateBasicMod = async (mod: Mod, rank: number): Promise } context.drawImage(await loadImage(frame), 0, 0); - return canvas.encode('png'); + const outterCanvas = createCanvas(width, 370); + const outterContext = outterCanvas.getContext('2d'); + + const image = await canvas.encode('png'); + outterContext.drawImage(await loadImage(image), 0, -80); + + return outterCanvas.encode('png'); }; export const generateRivenMod = async (riven: RivenMod): Promise => { diff --git a/tests/generator.spec.ts b/tests/generator.spec.ts index dc71a81..80041ea 100644 --- a/tests/generator.spec.ts +++ b/tests/generator.spec.ts @@ -26,7 +26,7 @@ describe('Generate a mod', () => { const mod = find.findItem(mods[i]) as Mod; if (!mod) continue; const isRiven = mod.name?.includes('Riven'); - const modCanvas = isRiven ? await generateRivenMod(mod as RivenMod) : await generateBasicMod(mod, 3); + const modCanvas = isRiven ? await generateRivenMod(mod as RivenMod) : await generateBasicMod(mod, 0); if (!modCanvas) assert.equal(true, false, 'Failed to generate mod'); writeFileSync(join('.', 'assets', 'tests', `${mod.name}.png`), modCanvas);