first commit
This commit is contained in:
commit
67eb7fa315
13 changed files with 943 additions and 0 deletions
20
ascii_writer/README.md
Normal file
20
ascii_writer/README.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# ASCII Writer
|
||||
|
||||
Une bibliothèque python pour dessiner avec du texte brut dans le style ASCII (mais avec Unicode).
|
||||
Par Manetta Berends
|
||||
|
||||
## Système
|
||||
- Linux
|
||||
- OSX
|
||||
|
||||
## Dépendance
|
||||
Ce site peut aider à l'installation: https://avoidsoftware.sarahgarcin.com/dependances.html
|
||||
|
||||
- Python 3
|
||||
- Asciiwriter ```pip3 install asciiwriter```
|
||||
|
||||
## Marche à suivre
|
||||
- Télécharger les fichiers .py
|
||||
- Ouvrir le terminal et lancer le script python souhaité: `python3 line.py`
|
||||
- Le résultat s'affiche dans le terminal
|
||||
-Vous pouvez ensuite tester les autres exemples présents dans le dossier et modifier les variables et le texte dans les fichiers Python.
|
||||
28
ascii_writer/line.py
Normal file
28
ascii_writer/line.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
Draws a single, vertical line
|
||||
"""
|
||||
|
||||
from asciiWriter.patterns import vertical
|
||||
from asciiWriter.utils import make_lines, visit, print_lines
|
||||
from asciiWriter.marks import sentence, space
|
||||
|
||||
# Set the canvas
|
||||
width = 75
|
||||
height = 75
|
||||
|
||||
# Define the line, most importantly it's position
|
||||
pattern = vertical(20)
|
||||
# We're going to fill the line with a text
|
||||
mark = sentence('AVOID SOFTWARE ')
|
||||
# Set the character for the 'blank' space
|
||||
blank = space()
|
||||
|
||||
# Make a canvas
|
||||
lines = make_lines(width, height)
|
||||
# Draw the result
|
||||
result = visit(lines, pattern, mark, blank)
|
||||
|
||||
# Print the result
|
||||
print_lines(result)
|
||||
30
ascii_writer/line_random.py
Normal file
30
ascii_writer/line_random.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
Draws a single just like line.py but does so
|
||||
using a 'random' character
|
||||
"""
|
||||
|
||||
from asciiWriter.patterns import vertical
|
||||
from asciiWriter.utils import make_lines, visit, print_lines
|
||||
from asciiWriter.marks import random, space
|
||||
|
||||
# Set the canvas
|
||||
width = 75
|
||||
height = 75
|
||||
|
||||
# Define the line, most importantly it's position
|
||||
image_pattern = vertical(20)
|
||||
# We're going to fill the line with random selections
|
||||
# from the '%$&@!*' chars
|
||||
mark = random('%$&@!*')
|
||||
# Set the character for the 'blank' space
|
||||
blank = space()
|
||||
|
||||
# Make a canvas
|
||||
lines = make_lines(width, height)
|
||||
# Draw the result
|
||||
result = visit(lines, image_pattern, mark, blank)
|
||||
|
||||
# Print the result
|
||||
print_lines(result)
|
||||
39
ascii_writer/repeated_lines.py
Normal file
39
ascii_writer/repeated_lines.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
Draws lines like line.py, but draws more than one
|
||||
"""
|
||||
|
||||
from asciiWriter.patterns import vertical
|
||||
from asciiWriter.utils import make_lines, visit, print_lines, merge
|
||||
from asciiWriter.marks import sentence, space
|
||||
|
||||
# Set the canvas
|
||||
width = 75
|
||||
height = 75
|
||||
|
||||
# We are going to draw multiple lines and collect them
|
||||
# in a list named 'layers'
|
||||
layers = []
|
||||
|
||||
# Set the position of the line, do this in a loop
|
||||
# from 10 to 75 in steps of then
|
||||
for x in range(10, 75, 10):
|
||||
# Define the line, x will start at 10 and grow in steps of 10
|
||||
image_pattern = vertical(x)
|
||||
# Fill the line with the sentence 'OPEN DESIGN COURSE '
|
||||
mark = sentence('AVOID SOFTWARE ')
|
||||
# Set the blank space
|
||||
blank = space()
|
||||
|
||||
# Make a canvas
|
||||
lines = make_lines(width, height)
|
||||
# Make a layer with the line
|
||||
layer = visit(lines, image_pattern, mark, blank)
|
||||
# Add the layer to the list of layers
|
||||
layers.append(layer)
|
||||
|
||||
# Merge the list of layers into a single layer
|
||||
result = merge(width, height, blank(), layers)
|
||||
# Print the result
|
||||
print_lines(result)
|
||||
36
ascii_writer/repeated_sinus.py
Normal file
36
ascii_writer/repeated_sinus.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from asciiWriter.patterns import sinus_vertical
|
||||
from asciiWriter.utils import make_lines, visit, print_lines, merge
|
||||
from asciiWriter.marks import sentence, space
|
||||
|
||||
# Define width and height of the output
|
||||
width = 80
|
||||
height = 70
|
||||
|
||||
# As we draw multiple sinoids we will collect
|
||||
# them in a list of layers
|
||||
layers = []
|
||||
|
||||
# Loop through an offset from -40 to 40 in steps of 10
|
||||
for x in range(-40, 40, 10):
|
||||
# Set the pattern with the changing offset
|
||||
pattern = sinus_vertical(period=40, amplitude=40, offset=x)
|
||||
# We use a sentence to draw the text
|
||||
mark = sentence('convivialité ')
|
||||
# Define a blank character
|
||||
blank = space()
|
||||
|
||||
# Make the canvas
|
||||
lines = make_lines(width, height)
|
||||
|
||||
# Draw the sinoid, but add it to the list
|
||||
result = visit(lines, pattern, mark, blank)
|
||||
# Add it the result to the list of layers
|
||||
layers.append(result)
|
||||
|
||||
# Merge the layers into one layer again
|
||||
merged = merge(width, height, blank(), layers)
|
||||
|
||||
# Print the result
|
||||
print_lines(merged)
|
||||
37
ascii_writer/repeated_sinus_amplitude_variation.py
Normal file
37
ascii_writer/repeated_sinus_amplitude_variation.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from asciiWriter.patterns import sinus_vertical
|
||||
from asciiWriter.utils import make_lines, visit, print_lines, merge
|
||||
from asciiWriter.marks import sentence, space
|
||||
|
||||
import random
|
||||
|
||||
# Define width and height of the output
|
||||
width = 75
|
||||
height = 75
|
||||
|
||||
# As we draw multiple sinoids we will collect
|
||||
# them in a list of layers
|
||||
layers = []
|
||||
|
||||
# Loop through an amplitude of -50 to 50 in steps of 10
|
||||
for amplitude in range(-50, 50, 10):
|
||||
# Set the pattern with the changing amplitude
|
||||
pattern = sinus_vertical(period=40, amplitude=amplitude)
|
||||
# We use a sentence to draw the text
|
||||
mark = sentence('convivialité ')
|
||||
# Define a blank character
|
||||
blank = space()
|
||||
|
||||
# Make the canvas
|
||||
lines = make_lines(width, height)
|
||||
# Draw the sinoid, but add it to the list
|
||||
result = visit(lines, pattern, mark, blank)
|
||||
# Add it the result to the list of layers
|
||||
layers.append(result)
|
||||
|
||||
# Merge the layers into one layer again
|
||||
merged = merge(width, height, blank(), layers)
|
||||
|
||||
# Print the result
|
||||
print_lines(merged)
|
||||
27
ascii_writer/sinus-text.py
Normal file
27
ascii_writer/sinus-text.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from asciiWriter.patterns import sinus_vertical
|
||||
from asciiWriter.utils import make_lines, visit, print_lines
|
||||
from asciiWriter.marks import sentence, space, single
|
||||
|
||||
# Define width and height of the output
|
||||
width = 75
|
||||
height = 75
|
||||
|
||||
# Set the pattern we use to draw, in this case a
|
||||
# sinoid, with period of 40 lines, and an amplitude
|
||||
# of 30 characters. Slightly less than half our canvas width
|
||||
pattern = sinus_vertical(period=40, amplitude=30)
|
||||
# We use a sentence to draw the text
|
||||
mark = sentence('tools shape pratices shape tools shape pratices ')
|
||||
# Define a blank character
|
||||
blank = single(' ')
|
||||
|
||||
# Make the canvas
|
||||
lines = make_lines(width, height)
|
||||
|
||||
# Draw the sinoid
|
||||
result = visit(lines, pattern, mark, blank)
|
||||
|
||||
# Output the result
|
||||
print_lines(result)
|
||||
51
ascii_writer/sinus.py
Normal file
51
ascii_writer/sinus.py
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
from asciiWriter.patterns import sinus_vertical
|
||||
from asciiWriter.utils import make_lines, visit, print_lines, merge
|
||||
from asciiWriter.marks import sentence, space
|
||||
|
||||
# Define width and height of the output
|
||||
width = 70
|
||||
height = 25
|
||||
|
||||
# As we draw multiple sinoids we will collect
|
||||
# them in a list of layers
|
||||
layers = []
|
||||
|
||||
# Loop through a range of X, X in steps of X
|
||||
# (the amount of loops is the amount of layers)
|
||||
for x in range(-50, 50, 5):
|
||||
# Set the pattern with the changing offset
|
||||
pattern = sinus_vertical(period=10, amplitude=40, offset=x)
|
||||
# We use a sentence to draw the text
|
||||
mark = sentence('▚▒▓▞')
|
||||
# Define a blank character
|
||||
blank = space(' ')
|
||||
|
||||
# Make the canvas
|
||||
lines = make_lines(width, height)
|
||||
|
||||
# Draw the sinoid, but add it to the list
|
||||
result = visit(lines, pattern, mark, blank)
|
||||
# Add it the result to the list of layers
|
||||
layers.append(result)
|
||||
|
||||
|
||||
|
||||
# Merge the layers into one layer again
|
||||
merged = merge(width, height, blank(), layers)
|
||||
|
||||
# Print the result
|
||||
print_lines(merged)
|
||||
|
||||
# Write the result in txt file
|
||||
# with open("sinus.txt", 'w') as newFile:
|
||||
# for els in merged:
|
||||
# for el in els:
|
||||
# # print(el)
|
||||
# # write each item on a new line
|
||||
# newFile.write(el)
|
||||
# print('Done')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue