manetta
3 years ago
6 changed files with 87 additions and 6 deletions
@ -0,0 +1,37 @@ |
|||
#!/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) |
@ -0,0 +1,44 @@ |
|||
#!/usr/bin/env python3 |
|||
|
|||
from asciiWriter.text import make_column, make_multi_column |
|||
from asciiWriter.utils import merge, print_lines, make_lines, translate |
|||
import math |
|||
|
|||
from os.path import join, dirname |
|||
|
|||
# Define width and height of the output |
|||
width = 100 |
|||
height = 250 # 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() |
|||
|
|||
# Import a hyphenator |
|||
|
|||
# Make an empty layers list |
|||
layers = [] |
|||
|
|||
# Transform the text into a column |
|||
try: |
|||
from hyphen import Hyphenator |
|||
h_en = Hyphenator('en_US') |
|||
lines, remaining = make_column(text, height=height, use_hyphenator=h_en, line_width=80, line_offset=0) |
|||
except ImportError: |
|||
lines, remaining = make_column(text, height=height, line_width=80, line_offset=0) |
|||
|
|||
# Transform the text into multiple columns |
|||
# lines, remaining = make_multi_column(text, height=height-3, use_hyphenator=h_en) |
|||
lines = translate(lines, x=10, 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) |
Loading…
Reference in new issue