Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. exports.run = async () => {
  2. const Canvas = require('canvas');
  3. const Discord = require('discord.js')
  4. const fs = require('fs')
  5.  
  6. // dimensão da imagem
  7. const canvas = Canvas.createCanvas(2000, 1495);
  8. // cria a imagem
  9. const ctx = canvas.getContext('2d');
  10.  
  11.  
  12.  
  13.  
  14. // Selecione a cor do traço
  15. ctx.strokeStyle = '#74037b';
  16. // Desenhe um retângulo com as dimensões de toda a tela
  17. ctx.strokeRect(0, 0, canvas.width, canvas.height);
  18.  
  19.  
  20.  
  21. ctx.font = '81px montserrat medium';
  22. ctx.fillStyle = '#ffffff';
  23. ctx.fillText("ImLuan_", 440, 280);
  24. const widthName = ctx.measureText("ImLuan_")
  25. ctx.font = '49px montserrat thin'
  26. ctx.fillText("#" + "5130", 440 + widthName.width, 290);
  27.  
  28.  
  29. ctx.font = '50px montserrat extralight';
  30. ctx.fillStyle = '#ffffff';
  31. ctx.fillText("LVL.", 159, 668);
  32. const widthNamea = ctx.measureText("LVL.")
  33. ctx.font = '70px montserrat medium'
  34. ctx.fillText(" 3", 159 + widthNamea.width, 668);
  35.  
  36. ctx.font = '60pt montserrat semibold';
  37. ctx.fillStyle = '#ffffff';
  38. ctx.fillText("3234", 160, 790);
  39. const widthNameb = ctx.measureText("3234")
  40. ctx.font = '50px montserrat extralight'
  41. ctx.fillText("xp", 160 + widthNameb.width, 790);
  42.  
  43. // // Selecione o tamanho da fonte e digite uma das fontes disponíveis nativamente
  44. // ctx.font = '81px montserrat medium';
  45. // // Selecione o estilo que será usado para preencher o texto
  46. // ctx.fillStyle = '#ffffff';
  47.  
  48. // ctx.fillText(message.author.username, 440, 280);
  49.  
  50. const x = 41;
  51. const y = 36;
  52. const s = 349;
  53.  
  54. ctx.fillStyle = 'red';
  55. ctx.beginPath()
  56. ctx.arc(x + (s / 2), y + (s / 2), s / 2, 0, 2 * Math.PI);
  57. ctx.fill()
  58.  
  59. ctx.closePath();
  60.  
  61. ctx.clip();
  62.  
  63. // const WIDTH = 668, HEIGHT = 500
  64.  
  65.  
  66.  
  67. const avatar = await Canvas.loadImage("https://cdn.discordapp.com/avatars/425997349135843328/4824dece3078e12de96b914c1f7bcca4.png?size=2048");
  68. ctx.drawImage(avatar, 41, 36, 350, 350);
  69.  
  70. const background = await Canvas.loadImage('./imagens/perfil.png');
  71. ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
  72.  
  73.  
  74. const buff = canvas.toBuffer()
  75. fs.writeFileSync("imagem.png", buff)
  76. console.log('opa')
  77. // const attachment = new Discord.Attachment(canvas.toBuffer(), 'welcome-image.png');
  78. // message.channel.send(attachment)
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement