Graphomania

This commit is contained in:
Madison Rye Progress
2024-07-14 13:28:12 -07:00
parent 975b0a4551
commit e88445fc5d
5 changed files with 413 additions and 496 deletions

View File

@ -6,11 +6,10 @@ one = 'And am I born to die? '
two = 'What will become of me? '
def latex(phrase: str, dx: int, dy: int, size: int, color: str) -> str:
def latex(phrase: str, dx: float, dy: float, size: int, color: str) -> str:
x = '' if dx == 0 else f'\\hspace{{{dx}em}}'
y = phrase if dy == 0 else f'\\raisebox{{{dy}em}}{{{phrase}}}'
extra = '' if math.floor(dx + dy) % 2 == 0 else '\n'
return f'\\fontspec{{Gentium Book Plus}}[Scale=0.9,Color={color},Ligatures=TeX]{x}{y}{extra}\n'
return f'\\fontspec{{Gentium Book Plus}}[Color={color},Ligatures=TeX]{x}{y}\n'
def html(phrase: str, dx: int, dy: int, size: int, color: float) -> str:
return f'<span style="position: relative; left: {dx}em; top: {dy}em; opacity: {color}">{phrase}</span>\n'
@ -42,10 +41,10 @@ def graphomania():
html_file.write(html(phrase, dx, dy, size, color))
for i in range(1, 200):
r = random.randint(1, 200)
rx = random.randint(1, 200)
ry = random.randint(1, 200)
for i in range(1, 150):
r = random.randint(1, 150)
rx = random.randint(1, 150)
ry = random.randint(1, 150)
dx = 0
dy = 0
size = 0
@ -61,9 +60,9 @@ def graphomania():
color = str(hex(math.floor((i - r) % 16)))[2] * 6
phrase = random.choice([two for p in range(0, i)] + [one for p in range(i, 200)])
phrase = random.choice([two for p in range(0, i)] + [one for p in range(i, 250)])
latex_file.write(latex(phrase, dx, dy, size, color))
latex_file.write(latex(phrase, dx * 1.2, dy, size, color))
latex_file.close()
html_file.close()