Options
All
  • Public
  • Public/Protected
  • All
Menu

Generated Overlay

ImageScript generated overlay

ImageScript generated overlay

// RGB colors of the gay pride flag
const prideColors = [0xff0018, 0xffa52c, 0xffff41, 0x008018, 0x0000f9, 0x86007d];

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

// Create a new image with the same dimensions as the avatar
const prideOverlay = Image.new(image.width, image.height);

prideOverlay.fill((x, y) => {
    // Get the color associated with the y position
    const color = prideColors[Math.floor(prideColors.length * y / image.height)];

    // Convert the color to RGB values
    const [r, g, b] = Image.colorToRGB(color); 

    // Convert the RGB values to a color with an alpha value of 50%
    return Image.rgbaToColor(r, g, b, 128);
});

// Composite the overlay onto the image
image.composite(prideOverlay, 0, 0);

Functions used

Image.load
Image.new
Image#fill
Image.colorToRGB
Image.rgbaToColor
Image#composite