chore: Refactor variable names for better readability
This commit is contained in:
parent
3bc97e8c07
commit
77a61bfd29
1 changed files with 5 additions and 5 deletions
10
main.py
10
main.py
|
@ -7,7 +7,7 @@ def imageToAsciiText(path, cell_size=(8, 8)):
|
|||
image = image.convert('L') # Convert to grayscale
|
||||
width, height = image.size
|
||||
pixels = np.array(image)
|
||||
ascii_characters = "@%#*+=-:. " # From darkest to lightest
|
||||
asciiCharacters = "@%#*+=-:. " # From darkest to lightest
|
||||
result = ""
|
||||
|
||||
for i in range(0, height, cell_size[1]):
|
||||
|
@ -15,15 +15,15 @@ def imageToAsciiText(path, cell_size=(8, 8)):
|
|||
cell = pixels[i:i+cell_size[1], j:j+cell_size[0]]
|
||||
if cell.size == 0:
|
||||
continue
|
||||
average_brightness = np.mean(cell)
|
||||
character_index = int(average_brightness * (len(ascii_characters) - 1) / 255)
|
||||
result += ascii_characters[character_index]
|
||||
averageBrightness = np.mean(cell)
|
||||
characterIndex = int(averageBrightness * (len(asciiCharacters) - 1) / 255)
|
||||
result += asciiCharacters[characterIndex]
|
||||
result += '\n'
|
||||
|
||||
print(result)
|
||||
return result
|
||||
|
||||
def asciiTextToImage(asciiText, outputPath, fontPath, fontSize):
|
||||
def asciiTextToImage(asciiText, fontPath, fontSize):
|
||||
# Split the ASCII art into lines
|
||||
lines = asciiText.split('\n')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue