Options
All
  • Public
  • Public/Protected
  • All
Menu

ImageScript join message

ImageScript join message

const avatar = Image.load('https://cdn.discordapp.com/avatars/687945863053443190/43022bb80ae031830866caacc18312de.png?size=1024');
const avgAvatarColor = avatar.averageColor();

const image = Image.new(1024, 256, avgAvatarColor);
image.lightness(0.75);

let border = Image.new(image.width, image.height);
border.fill((x, y) => {
    const alpha = Math.max(
        (Math.max(x, border.width - x) / border.width) ** 10,
        (Math.max(y, border.height - y) / border.height) ** 5
    );
    return avgAvatarColor & 0xffffff00 | alpha * 0xff;
});
border.lightness(0.25);

image.composite(border, 0, 0);

avatar.resize(image.height * 0.75, Image.RESIZE_AUTO);
avatar.cropCircle();
image.composite(avatar, image.width * 0.05, image.height / 8);

const text = Image.renderText(128, avgAvatarColor > 0x808080ff ? 0x000000ff : 0xffffffff, 'Roboto', '@matmen#0911 just joined!');
text.resize(image.width - image.width * 0.2 - image.height * 0.75, Image.RESIZE_AUTO);

image.composite(text, image.width * 0.1 + image.height * 0.75, image.height / 2 - text.height / 2);

Functions used

Image.load
Image#averageColor
Image.new
Image#lightness
Image#fill
Image#resize
Image#cropCircle
Image#composite
Image.renderText