Functioning image coloring
@ -1,5 +1,11 @@
|
||||
from redbot.core import data_manager
|
||||
|
||||
from .conquest import Conquest
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Conquest(bot))
|
||||
async def setup(bot):
|
||||
cog = Conquest(bot)
|
||||
data_manager.bundled_data_path(cog)
|
||||
await cog.load_data()
|
||||
|
||||
bot.add_cog(cog)
|
||||
|
@ -1,7 +1,12 @@
|
||||
from io import BytesIO
|
||||
|
||||
from PIL import Image
|
||||
from redbot.core import Config, commands
|
||||
from redbot.core.bot import Red
|
||||
|
||||
import discord
|
||||
import numpy as np
|
||||
from redbot.core.data_manager import bundled_data_path
|
||||
from skimage.color import rgb2lab, rgb2gray, lab2rgb
|
||||
from skimage.io import imread, imshow
|
||||
import matplotlib.pyplot as plt
|
||||
@ -23,10 +28,28 @@ class Conquest(commands.Cog):
|
||||
|
||||
self.config.register_guild(**default_guild)
|
||||
|
||||
self.assets = None
|
||||
|
||||
async def red_delete_data_for_user(self, **kwargs):
|
||||
"""Nothing to delete"""
|
||||
return
|
||||
|
||||
async def load_data(self):
|
||||
self.assets = bundled_data_path(self) / "assets"
|
||||
|
||||
@commands.command()
|
||||
async def conquest(self, ctx: commands.Context):
|
||||
await ctx.send("Hello world")
|
||||
async def conquest(self, ctx: commands.Context, region: int, color: str):
|
||||
|
||||
im = Image.open(self.assets / "simple_blank_map/blank.jpg")
|
||||
im2 = Image.new("RGB", im.size, color)
|
||||
mask = Image.open(self.assets / f"simple_blank_map/masks/{region}.jpg").convert('L')
|
||||
|
||||
out: Image.Image = Image.composite(im, im2, mask)
|
||||
|
||||
output_buffer = BytesIO()
|
||||
out.save(output_buffer, "jpeg")
|
||||
output_buffer.seek(0)
|
||||
|
||||
# TODO: Save the map in between
|
||||
|
||||
await ctx.send(file=discord.File(fp=output_buffer, filename="map.jpg"))
|
||||
|
Before Width: | Height: | Size: 345 KiB After Width: | Height: | Size: 345 KiB |
Before Width: | Height: | Size: 413 KiB After Width: | Height: | Size: 413 KiB |
BIN
conquest/data/assets/simple_blank_map.gif
Normal file
After Width: | Height: | Size: 110 KiB |
BIN
conquest/data/assets/simple_blank_map/blank.jpg
Normal file
After Width: | Height: | Size: 312 KiB |
BIN
conquest/data/assets/simple_blank_map/masks/1.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
conquest/data/assets/simple_blank_map/numbered.jpg
Normal file
After Width: | Height: | Size: 334 KiB |
BIN
conquest/data/assets/simple_blank_map/original.jpg
Normal file
After Width: | Height: | Size: 596 KiB |