@ Mufeed . .
, , - , Python. . , b, g ( artist emacs..):
letter_definitions = {
'b': Letter("""
****************
******************
***** *****
*** ***
*** ****
*** ****
*** ******
******************
*********************
*** * *****
*** ******
*** *****
*** ****
*** ****
*** ****
*** ****
*** **********
*********************
*****************
"""),
'g': Letter("""
****************
*** * **** **
*** *****
****
****
*****
****
****
**** ************
**** *************
***** *
***** *
***** **
****** *
******* **
********* *****
*************
"""),
'i': Letter("""
+---+
|***|
+---+
+-+
|*|
|*|
|*|
|*|
|*|
|*|
+-+
"""),
}
Letter // ( __init__) ( add_to_buffer()):
import textwrap
class Letter(object):
def __init__(self, shape):
self.shape = textwrap.dedent(shape).split('\n')
while self.shape[0] == '':
self.shape = self.shape[1:]
while self.shape[-1] == '':
self.shape = self.shape[:-1]
self.height = len(self.shape)
self.width = max(len(line) for line in self.shape)
self.baseline = self.height
def add_to_buffer(self, buffer, x, y):
"Write this letter shape to a 2-dimensional buffer at position x, y."
y += buffer.baseline - self.baseline
for lineno, line in enumerate(self.shape):
for charpos, ch in enumerate(line):
buffer[x + charpos, y + lineno] = ch
TextLine, () 2- , , , /:
class TextLine(object):
def __init__(self, letters):
self.letters = letters
self.width = sum(letter.width for letter in self.letters)
self.width += len(self.letters) - 1
self.height = max(letter.height for letter in self.letters)
self.baseline = self.height
self.buffer = [' '] * (self.width * self.height)
x = 0
for letter in self.letters:
letter.add_to_buffer(self, x, 0)
x += letter.width + 1
def __setitem__(self, (x, y), ch):
self.buffer[y * self.width + x] = ch
def __str__(self):
chunks = []
for i in range(0, len(self.buffer), self.width):
chunk = self.buffer[i:i + self.width]
chunks.append(''.join(chunk))
return '\n'.join(chunks)
, print_big() big_text() :
def big_text(text):
lines = text.splitlines(False)
res = []
for line in lines:
letters = [letter_definitions[ch] for ch in line]
text_line = TextLine(letters)
res.append(str(text_line))
return '\n\n'.join(res)
, , , , :
print big_text('big')
:
****************
******************
***** ***** ****************
*** *** *** * **** **
*** **** *** *****
*** **** ****
*** ****** ****
****************** +---+ *****
********************* |***| ****
*** * ***** +---+ ****
*** ****** **** ************
*** ***** +-+ **** *************
*** **** |*| ***** *
*** **** |*| ***** *
*** **** |*| ***** **
*** **** |*| ****** *
*** ********** |*| ******* **
********************* |*| ********* *****
***************** +-+ *************