_
BIN
AnimeFont/a-.jpg
Normal file
After Width: | Height: | Size: 380 KiB |
BIN
AnimeFont/a.jpg
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
AnimeFont/b-.webp
Normal file
After Width: | Height: | Size: 870 KiB |
BIN
AnimeFont/b.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
AnimeFont/c.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
AnimeFont/d.png
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
AnimeFont/e-.webp
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
AnimeFont/e.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
AnimeFont/f-.png
Normal file
After Width: | Height: | Size: 1.6 MiB |
BIN
AnimeFont/f.png
Normal file
After Width: | Height: | Size: 247 KiB |
BIN
AnimeFont/g.png
Normal file
After Width: | Height: | Size: 122 KiB |
BIN
AnimeFont/h-.jpg
Normal file
After Width: | Height: | Size: 62 KiB |
BIN
AnimeFont/h.jpg
Normal file
After Width: | Height: | Size: 81 KiB |
BIN
AnimeFont/i-.jpg
Normal file
After Width: | Height: | Size: 200 KiB |
BIN
AnimeFont/i.jpg
Normal file
After Width: | Height: | Size: 163 KiB |
BIN
AnimeFont/j.png
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
AnimeFont/k-.png
Normal file
After Width: | Height: | Size: 730 KiB |
BIN
AnimeFont/k.png
Normal file
After Width: | Height: | Size: 313 KiB |
BIN
AnimeFont/l.jpg
Normal file
After Width: | Height: | Size: 34 KiB |
BIN
AnimeFont/m-.jpg
Normal file
After Width: | Height: | Size: 272 KiB |
BIN
AnimeFont/m.jpg
Normal file
After Width: | Height: | Size: 101 KiB |
104
AnimeFont/main.py
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
import string
|
||||||
|
import pygame
|
||||||
|
import os
|
||||||
|
|
||||||
|
pygame.init() # initiate pygame
|
||||||
|
|
||||||
|
pygame.display.set_caption('Pygame') # set the window name
|
||||||
|
|
||||||
|
letter_height = 80
|
||||||
|
WINDOW_SIZE = (1, 0) # set up window size
|
||||||
|
|
||||||
|
screen = pygame.display.set_mode(WINDOW_SIZE, 0, 32) # initiate screen
|
||||||
|
|
||||||
|
|
||||||
|
def filter_text(text):
|
||||||
|
t = list(map(lambda s: s.lower(), [s for s in text]))
|
||||||
|
|
||||||
|
i_to_r = []
|
||||||
|
for i, letter in enumerate(t):
|
||||||
|
if letter not in string.ascii_lowercase + " ":
|
||||||
|
i_to_r.append(i)
|
||||||
|
|
||||||
|
load = 0
|
||||||
|
for i in i_to_r:
|
||||||
|
del t[i - load]
|
||||||
|
load += 1
|
||||||
|
|
||||||
|
return "".join(t)
|
||||||
|
|
||||||
|
|
||||||
|
def get_letters(letter_height, path=None):
|
||||||
|
|
||||||
|
letters = {letter.split(".")[0]: pygame.image.load(path + letter).convert() for letter in os.listdir(path)
|
||||||
|
if (letter.endswith(".png") or letter.endswith(".jpg")) and "-" not in letter}
|
||||||
|
|
||||||
|
for key, letter in letters.items():
|
||||||
|
s = letter.get_width() / letter.get_height()
|
||||||
|
letters[key] = pygame.transform.scale(letters[key], (int(letter_height * s), letter_height))
|
||||||
|
|
||||||
|
return letters
|
||||||
|
|
||||||
|
|
||||||
|
def get_word_length(word, letters):
|
||||||
|
return sum([letters[letter].get_width() for letter in word])
|
||||||
|
|
||||||
|
|
||||||
|
def get_image(text, letters, letter_height, bg=(54, 57, 63)):
|
||||||
|
text = filter_text(text)
|
||||||
|
t = text.split(" ")
|
||||||
|
word_lengths = list(map(lambda x: get_word_length(x, letters), t))
|
||||||
|
max_length = max(word_lengths)
|
||||||
|
if len(word_lengths) > 3:
|
||||||
|
max_length *= 2
|
||||||
|
lines = 1
|
||||||
|
cl = 0
|
||||||
|
i = 0
|
||||||
|
|
||||||
|
# getting image size
|
||||||
|
for w, l in zip(t, word_lengths):
|
||||||
|
if cl + l > max_length:
|
||||||
|
cl = l
|
||||||
|
lines += 1
|
||||||
|
else:
|
||||||
|
cl += l
|
||||||
|
|
||||||
|
if i != len(t) - 1:
|
||||||
|
if cl + (letter_height * 0.5) > max_length:
|
||||||
|
cl = 0
|
||||||
|
lines += 1
|
||||||
|
else:
|
||||||
|
cl += (letter_height * 0.5)
|
||||||
|
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
# creating surface
|
||||||
|
sur = pygame.Surface((max_length, lines * letter_height))
|
||||||
|
sur.fill(bg)
|
||||||
|
|
||||||
|
# rendering text onto surface
|
||||||
|
pos = [0, 0]
|
||||||
|
i = 0
|
||||||
|
for w, l in zip(t, word_lengths):
|
||||||
|
if pos[0] + l > max_length:
|
||||||
|
pos[0] = 0
|
||||||
|
pos[1] += letter_height
|
||||||
|
for letter in w:
|
||||||
|
sur.blit(letters[letter], pos)
|
||||||
|
pos[0] += letters[letter].get_width()
|
||||||
|
|
||||||
|
else:
|
||||||
|
for letter in w:
|
||||||
|
sur.blit(letters[letter], pos)
|
||||||
|
pos[0] += letters[letter].get_width()
|
||||||
|
|
||||||
|
if i != len(t) - 1:
|
||||||
|
if pos[0] + (letter_height * 0.5) > max_length:
|
||||||
|
pos[0] = 0
|
||||||
|
pos[1] += letter_height
|
||||||
|
else:
|
||||||
|
pos[0] += (letter_height * 0.5)
|
||||||
|
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
return sur
|
BIN
AnimeFont/n.jpg
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
AnimeFont/o-.jpg
Normal file
After Width: | Height: | Size: 169 KiB |
BIN
AnimeFont/o.jpg
Normal file
After Width: | Height: | Size: 60 KiB |
BIN
AnimeFont/p-.jpg
Normal file
After Width: | Height: | Size: 158 KiB |
BIN
AnimeFont/p.jpg
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
AnimeFont/q-.jpg
Normal file
After Width: | Height: | Size: 94 KiB |
BIN
AnimeFont/q.jpg
Normal file
After Width: | Height: | Size: 45 KiB |
BIN
AnimeFont/r-.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
AnimeFont/r.jpg
Normal file
After Width: | Height: | Size: 232 KiB |
BIN
AnimeFont/s-.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
AnimeFont/s.jpg
Normal file
After Width: | Height: | Size: 49 KiB |
BIN
AnimeFont/t-.jpg
Normal file
After Width: | Height: | Size: 60 KiB |
BIN
AnimeFont/t.jpg
Normal file
After Width: | Height: | Size: 89 KiB |
BIN
AnimeFont/u.jpg
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
AnimeFont/v-.jpg
Normal file
After Width: | Height: | Size: 268 KiB |
BIN
AnimeFont/v.jpg
Normal file
After Width: | Height: | Size: 75 KiB |
BIN
AnimeFont/w-.jpg
Normal file
After Width: | Height: | Size: 8.5 KiB |
BIN
AnimeFont/w.jpg
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
AnimeFont/x-.jpg
Normal file
After Width: | Height: | Size: 175 KiB |
BIN
AnimeFont/x-.png
Normal file
After Width: | Height: | Size: 8.7 MiB |
BIN
AnimeFont/x.png
Normal file
After Width: | Height: | Size: 899 KiB |
BIN
AnimeFont/y.png
Normal file
After Width: | Height: | Size: 57 KiB |
BIN
AnimeFont/z.png
Normal file
After Width: | Height: | Size: 150 KiB |
42
bot.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import discord
|
||||||
|
import random
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
|
intents = discord.Intents.all()
|
||||||
|
|
||||||
|
|
||||||
|
client = commands.Bot(command_prefix=lambda x, y: "HELLO", intents=intents)
|
||||||
|
|
||||||
|
|
||||||
|
@client.event
|
||||||
|
async def on_ready():
|
||||||
|
print("KawaiiFont is ready.")
|
||||||
|
await client.change_presence(status=discord.Status.online, activity=discord.Game(".your text"))
|
||||||
|
|
||||||
|
|
||||||
|
@client.command()
|
||||||
|
@commands.has_permissions(administrator=True)
|
||||||
|
async def reload(ctx):
|
||||||
|
try:
|
||||||
|
for ext in os.listdir("extensions"):
|
||||||
|
if ext.endswith(".py"):
|
||||||
|
try:
|
||||||
|
client.unload_extension(f"extensions.{ext[:-3]}")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
client.load_extension(f"extensions.{ext[:-3]}")
|
||||||
|
await ctx.send(f"Reloaded all extensions successfully.")
|
||||||
|
except Exception as e:
|
||||||
|
await ctx.send(e)
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
for ext in os.listdir("extensions"):
|
||||||
|
if ext.endswith(".py"):
|
||||||
|
client.load_extension(f"extensions.{ext[:-3]}")
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
|
client.run("") # id here
|
BIN
extensions/__pycache__/functions.cpython-39.pyc
Normal file
27
extensions/functions.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
from KawaiiFont.AnimeFont.main import *
|
||||||
|
|
||||||
|
|
||||||
|
class Functions(commands.Cog):
|
||||||
|
|
||||||
|
def __init__(self, client):
|
||||||
|
self.client = client
|
||||||
|
self.letter_height = 300
|
||||||
|
self.letters = get_letters(self.letter_height, "AnimeFont/")
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
|
async def on_message(self, message):
|
||||||
|
if message.author == self.client.user:
|
||||||
|
return
|
||||||
|
if str(message.content)[0] == ".":
|
||||||
|
await message.channel.purge(limit=1)
|
||||||
|
img = get_image(str(message.content)[1:], self.letters, self.letter_height)
|
||||||
|
pygame.image.save(img, f"AnimeFont/KawaiiFolder/KawaiiFont - {str(message.content)}.png")
|
||||||
|
with open(f"AnimeFont/KawaiiFolder/KawaiiFont - {str(message.content)}.png", "rb") as f:
|
||||||
|
picture = discord.File(f)
|
||||||
|
await message.channel.send(file=picture)
|
||||||
|
|
||||||
|
|
||||||
|
def setup(client):
|
||||||
|
client.add_cog(Functions(client))
|