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
|
image = image.convert('L') # Convert to grayscale
|
||||||
width, height = image.size
|
width, height = image.size
|
||||||
pixels = np.array(image)
|
pixels = np.array(image)
|
||||||
ascii_characters = "@%#*+=-:. " # From darkest to lightest
|
asciiCharacters = "@%#*+=-:. " # From darkest to lightest
|
||||||
result = ""
|
result = ""
|
||||||
|
|
||||||
for i in range(0, height, cell_size[1]):
|
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]]
|
cell = pixels[i:i+cell_size[1], j:j+cell_size[0]]
|
||||||
if cell.size == 0:
|
if cell.size == 0:
|
||||||
continue
|
continue
|
||||||
average_brightness = np.mean(cell)
|
averageBrightness = np.mean(cell)
|
||||||
character_index = int(average_brightness * (len(ascii_characters) - 1) / 255)
|
characterIndex = int(averageBrightness * (len(asciiCharacters) - 1) / 255)
|
||||||
result += ascii_characters[character_index]
|
result += asciiCharacters[characterIndex]
|
||||||
result += '\n'
|
result += '\n'
|
||||||
|
|
||||||
print(result)
|
print(result)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def asciiTextToImage(asciiText, outputPath, fontPath, fontSize):
|
def asciiTextToImage(asciiText, fontPath, fontSize):
|
||||||
# Split the ASCII art into lines
|
# Split the ASCII art into lines
|
||||||
lines = asciiText.split('\n')
|
lines = asciiText.split('\n')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue