-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3-bitmap.py
More file actions
70 lines (58 loc) · 2.48 KB
/
3-bitmap.py
File metadata and controls
70 lines (58 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
BITMAP = """
....................................................................
************** * *** ** * ******************************
********************* ** ** * * ****************************** *
** ***************** ******************************
************* ** * **** ** ************** *
********* ******* **************** * *
******** *************************** *
* * **** *** *************** ****** ** *
**** * *************** *** *** *
****** ************* ** ** *
******** ************* * ** ***
******** ******** * *** ****
********* ****** * **** ** * **
********* ****** * * *** * *
****** ***** ** ***** *
***** **** * ********
***** **** *********
**** ** ******* *
*** * *
** * *
...................................................................."""
import sys,time
'''
takes a multi-line bitmap with ' ' indicated as noman's land
'''
def bit_print(bitmap):
print('Enter message to display using bit-map. Use uppercase for first char of each word')
message=input("> ")
# modify message to exclude spaces
message=''.join(message.split(' '))
massage_bitmap=[]
bit_lines=bitmap.splitlines()
message_bitmap=[]
for line in bit_lines:
for c in line:
message_bitmap.append(c)
message_bitmap.append('\n')
bitmap_len=len(message_bitmap)
curr_pos=0
while(curr_pos<bitmap_len):
curr_letter=0
while(curr_letter<len(message)):
if curr_pos>=bitmap_len:
break
if (message_bitmap[curr_pos]!=' ') and (message_bitmap[curr_pos]!='\n'):
message_bitmap[curr_pos]=message[curr_letter]
curr_letter+=1
curr_pos+=1
try:
while True:
print('\nPress Ctrl-C to stop.\n')
print(''.join(message_bitmap))
time.sleep(2)
except:
sys.exit()
if __name__=='__main__':
bit_print(BITMAP)