a python library to draw with ASCII (but with Unicode)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.0 KiB

#!/usr/bin/env python3
from asciiWriter.text import make_column, make_multi_column
from asciiWriter.utils import merge, print_lines, make_lines, translate
from asciiWriter.marks import single
import math
from os.path import join, dirname
# Define width and height of the output
width = 80
height = 265 # it would be nice to make an "automated fit" function, that defines the height based on an attempt to fill both columns.
# Import a text
text = open(join(dirname(__file__), 'data', 'language.txt')).read()
# Collect layers in a list
layers = []
# Transform the text into multiple columns
lines, remaining = make_multi_column(text, height=height, column_width=35, column_count=2, column_gap=5)
# Move the lines 3 characters to the right
lines = translate(lines, x=3, y=0)
# Create an background
background = make_lines(width, height, ' ')
# Add all your layers to the layers list
layers.append(background)
layers.append(lines)
# Merge the layers into one layer again
merged = merge(width, height, ' ', layers)
# Print the result
print_lines(merged)