Skip to content

Commit

Permalink
still still working on sys.argv
Browse files Browse the repository at this point in the history
  • Loading branch information
kamicavi committed Sep 26, 2018
1 parent 758d7d4 commit ebad76d
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 34 deletions.
1 change: 1 addition & 0 deletions colourTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print(type(input('? ')))
97 changes: 63 additions & 34 deletions pyMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@
import time
import os

colour = 92
interval = 0.052
spaceFreq = 0.8
charRange = (32,126)

colours = {
'light grey' :'89',
'grey' :'90',
'red' :'91',
'green' :'92',
'yellow' :'93',
'blue' :'94',
'pink' :'95',
'light blue' :'96',
'white' :'97'
}

usage = '''Usage:
-f '<filepath>' Read parameters from <filepath> (not currently implemented).
-p Prompts for parameters.
Expand All @@ -22,16 +39,15 @@
if arguments[i] == '-h':
print(usage)

if arguments[i] == '-p':
elif arguments[i] == '-p':
while not colourValid:
try:
colour = raw_input('What colour would you like? (light grey, grey, red, green, blue, light blue, pink, white, or a colour escape code.) ').lower()
colour = input('What colour would you like? (light grey, grey, red, green, blue, light blue, pink, white, or a colour escape code.) ').lower()
if type(colour) == 'str':
colour = colours[colour]

elif type(colour) == 'int':
colour = int(colour)


colourValid = True

Expand All @@ -40,60 +56,73 @@

while not intervalValid:
try:
interval = float(raw_input('What would you like the interval between lines to be? (seconds) (suggested: 0.052)'))
interval = float(input('What would you like the interval between lines to be? (seconds) (suggested: 0.052)'))
intervalValid = True

except TypeError:
print('The interval must be a decimal number.')

while not spaceFreqValid:
try:
spaceFreq = float(raw_input('What would you like the of spaces to be? (suggested: 0.8) '))
spaceFreq = float(input('What would you like the of spaces to be? (suggested: 0.8) '))
spaceFreqValid = True


except TypeError:
print('The frequency must be a decimal number')

while not charRangeValid:
try:
charRange = tuple(input('What would characters would you like to include? (all basic ASCII characters are (32,126))'))
charRangeValid = True

except TypeError:
print('The frequency must be a decimal number')#

while not charRangeValid:
try:
charRange = tuple(raw_input('What would characters would you like to include? (all basic ASCII characters are (32,126))'))
charRangeValid = True

except TypeError:
print('The character range should be to ASCII values, in a tuple')

if arguments[i] == '-c'


colour = 92
interval = 0.052
spaceFreq = 0.8
charRange = (32,126)

colours = {
'light grey' :'89',
'grey' :'90',
'red' :'91',
'green' :'92',
'yellow' :'93',
'blue' :'94',
'pink' :'95',
'light blue' :'96',
'white' :'97'
}

elif arguments[i] == '-c':
colour = arguments[i + 1]
del arguments[i + 1]

try:
int(colour)

except ValueError:
try:
colour = colours[colour]

except KeyError:
print('Not ')

colourValid = True

except KeyError:
print('Not a valid colour.')

elif arguments[i] == '-i':
interval = arguments[i + 1]
del arguments[i + 1]

elif arguments[i] == '-s':
spaceFreq = arguments[i + 1]
del arguments[i + 1]

elif arguments[i]


os.popen('clear')

while True:
width = os.popen('stty size').read().split(' ')[1]
line = ""

for i in range(int(width)):
temp = random.randint(charRange)
line = line + str(chr(temp))

for i in range(int(int(width)/spaceFreq)):
point = random.randint(0,int(width)-1)
line = list(line)
line[point] = ' '
line = ''.join(line)

print("\033[" + str(colour) + 'm' + str(line) + "\033[0m")
time.sleep(interval)

0 comments on commit ebad76d

Please sign in to comment.