Use numbers as mask, probably need to switch to png soon
This commit is contained in:
parent
5203aba042
commit
4118f1a91f
@ -1,7 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
from io import BytesIO
|
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
@ -170,21 +169,22 @@ class Conquest(commands.Cog):
|
|||||||
await ctx.maybe_send_embed("No map is currently set. See `[p]conquest set map`")
|
await ctx.maybe_send_embed("No map is currently set. See `[p]conquest set map`")
|
||||||
return
|
return
|
||||||
|
|
||||||
await ctx.send(file=discord.File(fp=self.data_path / self.current_map / "current.jpg", filename="current.jpg"))
|
|
||||||
await ctx.send(file=discord.File(fp=self.asset_path / self.current_map / "numbers.jpg", filename="numbers.jpg"))
|
|
||||||
|
|
||||||
current_map = Image.open(self.data_path / self.current_map / "current.jpg")
|
current_map = Image.open(self.data_path / self.current_map / "current.jpg")
|
||||||
numbers = Image.open(self.asset_path / self.current_map / "numbers.jpg").convert("L")
|
numbers = Image.open(self.asset_path / self.current_map / "numbers.jpg").convert("L")
|
||||||
|
|
||||||
inverted_map = ImageOps.invert(current_map)
|
inverted_map = ImageOps.invert(current_map)
|
||||||
|
|
||||||
current_numbered_jpg: Image.Image = Image.composite(current_map, inverted_map, numbers)
|
current_numbered_jpg: Image.Image = Image.composite(current_map, inverted_map, numbers)
|
||||||
|
current_numbered_jpg.save(
|
||||||
|
self.data_path / self.current_map / "current_numbered.jpg", "jpeg"
|
||||||
|
)
|
||||||
|
|
||||||
output_buffer = BytesIO()
|
await ctx.send(
|
||||||
current_numbered_jpg.save(output_buffer, "jpeg")
|
file=discord.File(
|
||||||
current_numbered_jpg.seek(0)
|
fp=self.data_path / self.current_map / "current_numbered.jpg",
|
||||||
|
filename="current_numbered.jpg",
|
||||||
await ctx.send(file=discord.File(fp=output_buffer, filename="numbered_map.jpg"))
|
)
|
||||||
|
)
|
||||||
|
|
||||||
@conquest.command(name="take")
|
@conquest.command(name="take")
|
||||||
async def _conquest_take(self, ctx: commands.Context, regions: Greedy[int], *, color: str):
|
async def _conquest_take(self, ctx: commands.Context, regions: Greedy[int], *, color: str):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user