fixed some rendering bugs

This commit is contained in:
JISAUAY 2024-09-09 09:59:05 -05:00
parent 6735153a20
commit 752463329e
2 changed files with 10 additions and 9 deletions

BIN
fonts/scientifica.ttf Normal file

Binary file not shown.

View File

@ -7,10 +7,11 @@ import os
from PIL import Image, ImageFilter
import pygame as pg
IMAGE_PATH = 'sample-images/engine.PNG'
IMAGE_PATH = 'sample-images/sunflower.jpg'
FONT_PATH = 'fonts/scientifica.ttf'
BLUR_STRENGTH_1 = 1
BLUR_STRENGTH_2 = 2.5
BLUR_STRENGTH_2 = 1.2
DOG_THRESHOLD = 8
@ -31,7 +32,7 @@ if not os.path.exists('./debug/') and DEBUG:
os.makedirs('./debug')
# '█@?OPoci. '
CHARS = [
CHARS = list(reversed([
u'',
'@',
'?',
@ -42,7 +43,7 @@ CHARS = [
'i',
'.',
' '
]
]))
def main():
@ -81,7 +82,7 @@ def main():
text_grind_height = h / SCALED_HEIGHT
pg.init()
font = pg.font.SysFont("Monocraft Medium", 12)
font = pg.font.Font(FONT_PATH, 12)
window = pg.display.set_mode((text_grid_width * TEXT_WIDTH, text_grind_height * TEXT_HEIGHT))
y_offset = 0
@ -127,7 +128,7 @@ def main():
score = histogram[char]
most_common = char
rendered_char = font.render(most_common, 1, color_avg)
rendered_char = font.render(str(most_common), True, color_avg)
window.blit(rendered_char, (x * TEXT_WIDTH, y * TEXT_HEIGHT))
x_offset += SCALED_WIDTH
@ -144,7 +145,7 @@ def main():
# Draw only the ASCII edges
pg.init()
font = pg.font.SysFont("Monocraft Medium", 12)
font = pg.font.Font(FONT_PATH, 12)
window = pg.display.set_mode((text_grid_width * TEXT_WIDTH, text_grind_height * TEXT_HEIGHT))
y_offset = 0
@ -190,7 +191,7 @@ def main():
score = histogram[char]
most_common = char
rendered_char = font.render(most_common, 1, color_avg)
rendered_char = font.render(most_common, True, color_avg)
window.blit(rendered_char, (x * TEXT_WIDTH, y * TEXT_HEIGHT))
x_offset += SCALED_WIDTH
@ -202,7 +203,7 @@ def main():
pg.quit()
def subtract_colors(t1: tuple, t2: tuple) -> tuple: