userinfo: nothing is ever sized the same...
This commit is contained in:
		
							parent
							
								
									d19826f1e1
								
							
						
					
					
						commit
						338dc9aa95
					
				
					 1 changed files with 11 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -72,16 +72,16 @@ async function fetchQuestData() {
 | 
			
		|||
  questsFetch = Date.now() + 60 * 60 * 1000;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function nameplateBackground(color) {
 | 
			
		||||
function nameplateBackground(width, height, color, light = false) {
 | 
			
		||||
  return sharp(
 | 
			
		||||
    Buffer.from(`<svg viewBox="0 0 448 84" width="448" height="84" xmlns="http://www.w3.org/2000/svg">
 | 
			
		||||
    Buffer.from(`<svg viewBox="0 0 ${width} ${height}" width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg">
 | 
			
		||||
  <defs>
 | 
			
		||||
    <linearGradient id="nameplate">
 | 
			
		||||
      <stop offset="0%" stop-color="${color}1A" />
 | 
			
		||||
      <stop offset="100%" stop-color="${color}66" />
 | 
			
		||||
      <stop offset="100%" stop-color="${color}${light ? "66" : "4D"}" />
 | 
			
		||||
    </linearGradient>
 | 
			
		||||
  </defs>
 | 
			
		||||
  <rect x="0" y="0" width="448" height="84" fill="url('#nameplate')"/>
 | 
			
		||||
  <rect x="0" y="0" width="${width}" height="${height}" fill="url('#nameplate')"/>
 | 
			
		||||
</svg>`)
 | 
			
		||||
  );
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -515,13 +515,16 @@ userinfo.callback = async function (msg, line) {
 | 
			
		|||
        const static = await fetch(imageUrl)
 | 
			
		||||
          .then((res) => res.arrayBuffer())
 | 
			
		||||
          .then((b) => Buffer.from(b));
 | 
			
		||||
        const metadata = sharp(static).metadata();
 | 
			
		||||
 | 
			
		||||
        const bg_light = nameplateBackground(palette.lightBackground);
 | 
			
		||||
        const bg_light = nameplateBackground(metadata.width, metadata.height, palette.lightBackground, true);
 | 
			
		||||
        bg_light.composite([{input: static}]);
 | 
			
		||||
        const bg_dark = nameplateBackground(palette.darkBackground);
 | 
			
		||||
        const bg_dark = nameplateBackground(metadata.width, metadata.height, palette.darkBackground);
 | 
			
		||||
        bg_dark.composite([{input: static}]);
 | 
			
		||||
 | 
			
		||||
        const final = sharp({create: {width: 448, height: 168, channels: 4, background: "transparent"}});
 | 
			
		||||
        const final = sharp({
 | 
			
		||||
          create: {width: metadata.width, height: metadata.height * 2, channels: 4, background: "transparent"},
 | 
			
		||||
        });
 | 
			
		||||
        final.composite([
 | 
			
		||||
          {input: await bg_light.toBuffer(), gravity: "north"},
 | 
			
		||||
          {input: await bg_dark.toBuffer(), gravity: "south"},
 | 
			
		||||
| 
						 | 
				
			
			@ -552,6 +555,7 @@ userinfo.callback = async function (msg, line) {
 | 
			
		|||
        },
 | 
			
		||||
      ],
 | 
			
		||||
      image: {url: imageUrl},
 | 
			
		||||
      footer: `SKU ID: ${nameplate.sku_id}`,
 | 
			
		||||
    };
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue