Canvas

with Discord.Short you can create an image like you would do using JavaScript with html:

const canvas = new Discord.Canvas(200, 200); // width, height
const ctx = canvas.getContext('2d');

you can create simple shapes and text:

ctx.rect(10, 10, 30, 30); // x, y, width, height
ctx.ellipse(30, 40, 20, 20); // x, y, width, height
ctx.text('hello world', 20, 100, 20, 'arial'); // text, x, y, size?, font?

you can add a background and change the color of these shapes like this:

ctx.background('#121212'); // color (hex, rgb)
ctx.fill('rgb(255, 0, 130)'); // color (hex, rgb)

you can make masks...

ctx.beginMask('example'); // mask id
ctx.rect(20, 20, 50, 50);
ctx.closeMask();

and add them to shapes:

ctx.mask('example'); // mask id
ctx.fill('#4912fe');
ctx.rect(10, 10, 70, 70);

and if you want, you can use an svg:

ctx.svg('path/to/file.svg'); // filepath

Last updated