Skip to content

A Telegram bot for generating images based on a supplied function

Notifications You must be signed in to change notification settings

yurtsiv/image-draw-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ImageDrawBot

Bot username: @ImageDrawBot

A Telegram bot for generating images based on a supplied JavaScript function, which returns RGB color for each pixel coordinate.

Commands

/draw - Draw an image with origin located in the top left corner

/draw_center - Draw an image with origin located in the center (Cartesian coordinates)

/draw_hd - Draw an image in HD

/draw_center_hd - Draw an image in HD with Cartesian coordinates

/draw_fhd - Draw an image in Full HD

/draw_center_fhd - Draw an image in Full HD with Cartesian coordinates

/draw_2k - Draw an image in 2K

/draw_center_2k - Draw an image in 2K with Cartesian coordinates

/draw_4k - Draw an image in 4K

/draw_center_4k - Draw an image in 4K with Cartesian coordinates

Examples

Sierpinski triangle

Sierpinski triangles

Command
/draw (x, y) => {
  const c = x & y ? 0 : 255;

  return {
    r: c,
    g: c,
    b: c
  }
}

Fancy sine

Sine

Command
/draw_center_hd (x, y) => {
  const val = Math.floor(Math.sin(x / 30) * 100);

  if (val < (y + 10) && val > (y - 10)) {
    return {
      r: x,
      g: y,
      b: x - y
    }
  }

  return {
    r: 255,
    g: 255,
    b: 255
  }
}

Lovely heart

Sine

Command
/draw (x, y) => {
  const img = [0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0x00,0x00,0x00,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0x00,0x00,0x00,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0xff,0x00,0x2e,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0x00,0x2e,0xff,0x00,0x2e,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff];

  const newx = Math.floor(x/16);
  const newy = Math.floor(y/16);
  const offset = (newx*3 + newy * 48);

  return {
    r: img[offset],
    g: img[offset + 1],
    b: img[offset + 2]
  }
}

Your next wallpaper

Sine

Command
/draw_2k (x, y)  => {
  return {
    r: 0,
    g: 0,
    b: y === 0 ? 0 : x % y
  }
}

Running

  • docker pull stepy/image-draw-bot
  • docker run -d --env-file .env --publish 8001:8080 stepy/image-draw-bot

.env file:

BOT_TOKEN=<token>

About

A Telegram bot for generating images based on a supplied function

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published