From 877625245a72f3efb7c561da0c4cc09638d8bfae Mon Sep 17 00:00:00 2001 From: Cameron Ball Date: Fri, 10 Apr 2015 16:45:18 +0800 Subject: [PATCH 1/1] Initial commit --- README.md | 23 +++++++ animate.py | 51 ++++++++++++++++ applause.txt | 77 ++++++++++++++++++++++++ dance.txt | 193 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 344 insertions(+) create mode 100644 README.md create mode 100644 animate.py create mode 100644 applause.txt create mode 100644 dance.txt diff --git a/README.md b/README.md new file mode 100644 index 0000000..a57d580 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +A silly idea for producing animated ascii art. + +Usage +===== +The `load` function will load a text file and proceed to animate it: + +```python +import animate +animate.load("dance.txt") +``` + +You can optionally add a message to the animation: + +```python +import animate +animate.load("dance.txt", "Nice Meme!") +``` + +Text File Format +================ +The text file needs to include all frames of the animation. + +The first line of the text file must contain the number of lines per frame. Following that each frame must be drawn and separated by an empty line. Each frame must have the same number of lines as specified at the beginning of the file. See applause.txt and dance.txt for examples. diff --git a/animate.py b/animate.py new file mode 100644 index 0000000..70d904b --- /dev/null +++ b/animate.py @@ -0,0 +1,51 @@ +''' + (c) 2015 Cameron Ball, Ash Williams + All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, and/or sell copies of the Software, and to permit persons to + whom the Software is furnished to do so, provided that the above + copyright notice(s) and this permission notice appear in all copies of + the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. +''' + +import time + +def pad(output, numLines): + for i in range(0, numLines): + output += "\n" + + return output + +def load(filename, text = ''): + lines = []; + with open(filename) as f: + for line in f: + lines.append(line.rstrip()) + + linesPerFrame = int(lines[0]) + numLines = len(lines) - 1 + offset = 1 + + while True: + output = pad('', 100) + for i in range(offset, linesPerFrame+offset): + output += lines[i]+"\n" + + offset = (i+2) % numLines + time.sleep(1) + print(output + "\n" + text) + diff --git a/applause.txt b/applause.txt new file mode 100644 index 0000000..e752354 --- /dev/null +++ b/applause.txt @@ -0,0 +1,77 @@ +18 + |.--------_--_------------_--__--.| + || /\ |_)|_)| /\ | |(_ |_ || + ;;`,_/``\|__|__|__/``\|_| _)|__ ,:| + ((_(-,-----------.-.----------.-.)`) + \__ ) ,' `. \ _/ + : : |_________| : : + |-'| ,'-.-.--.-.`. |`-| + |_.| (( (* )(* ))) |._| + | | `.-`-'--`-'.' | | + |-'| | ,-.-.-. | |._| + | | |(|-|-|-|)| | | + :,': |_`-'-'-'_| ;`.; + \ \ ,' `. /._/ + \/ `._ /_______________\_,' / + \ / : ___________ : \,' + `.| | | | |,' + `.| | | | + | | | | + + + |.--------_--_------------_--__--.| + || /\ |_)|_)| /\ | |(_ |_ || + ;;`,_/``\|__|__|__/``\|_| _)|__ ,:| + ((_(-,-----------.-.----------.-.)`) + \__ ) |_________| \ _/ + : : ,'-.-.--.-.`. : : + |-'| (( ( * )( * ))) |`-| + |-.| `.-`-'--`-'.' |._| + | | | ,-.-.-. | | | + |_'| |(|-|-|-|)| |._| + :,': |_`-'-'-'_| ;`.; + \ \ ,' `. /._/ + \/ `._ /_______________\_,' / + \ / : ___________ : \,' + `.| | | | |,' + `.| | | | + | | | | + + |.--------_--_------------_--__--.| + || /\ |_)|_)| /\ | |(_ |_ || + ;;`,_/``\|__|__|__/``\|_| _)|__ ,:| + ((_(-,-----------.-.----------.-.)`) + \__ ) ,' `. \ _/ + : : |_________| : : + |-'| ,'-.-.--.-.`. |`-| + |_.| (( ( *)( *))) |._| + | | `.-`-'--`-'.' | | + |-'| | ,-.-.-. | |._| + | | |(|-|-|-|)| | | + :,': |_`-'-'-'_| ;`.; + \ \ ,' `. /._/ + \/ `._ /_______________\_,' / + \ / : ___________ : \,' + `.| | | | |,' + `.| | | | + | | | | + + + |.--------_--_------------_--__--.| + || /\ |_)|_)| /\ | |(_ |_ || + ;;`,_/``\|__|__|__/``\|_| _)|__ ,:| + ((_(-,-----------.-.----------.-.)`) + \__ ) |_________| \ _/ + : : ,'-.-.--.-.`. : : + |-'| (( ( * )( * ))) |`-| + |-.| `.-`-'--`-'.' |._| + | | | ,-.-.-. | | | + |_'| |(|-|-|-|)| |._| + :,': |_`-'-'-'_| ;`.; + \ \ ,' `. /._/ + \/ `._ /_______________\_,' / + \ / : ___________ : \,' + `.| | | | |,' + `.| | | | + | | | | + \ No newline at end of file diff --git a/dance.txt b/dance.txt new file mode 100644 index 0000000..e6b252b --- /dev/null +++ b/dance.txt @@ -0,0 +1,193 @@ +31 + o + | + ,'~'. + / \ + | ____|_ + | '___,,_' .----------------. + | ||(o |o)| ( KILL ALL HUMANS! ) + | ------- ,----------------' + | _____| -' + \ '####, + ------- + /________\ + ( ) |) + '_ ' ,------|\ + /_ / | |_\ + /_ /| | o| _\ __ + /_ / | | |\ _\____// | + ( ( | | | (_,_,_,___/ + \ _\ | ------| + \ _\|_________| + \ _\ \__\\__\ + |__| |__||__| + ||/__/ |__||__| + |__||__| + |__||__| + /__)/__) + /__//__/ + /__//__/ + /__//__/. + .' '. '. + (________)____) + + + o + | + ,'~'. + / \ + | ____|_ + | '___,,_' .----------------. + | ||(o |o)| ( KILL ALL HUMANS! ) + | ------- ,----------------' + | _____| -' + \ '####, + ------- + /________\ + ( ) |) + '_ ' ,------|\ + /_ / | |_\ + /_ /| | o| _\ __ + /_ / | | |\ _\____// | + ( ( | | | (_,_,_,___/ + \ _\ | ------| + \ _\|_________| + \ _\ \__\\__\ + |__| |__||__| + ||/__/ |__||__| + |__||__| + |__||__| + /__)/__) + /__//__/ + /__//__/. + .' '. '. + (________)____) + + + o + | + ,'~'. + / \ + | ____|_ + | '___,,_' .----------------. + | ||(o |o)| ( KILL ALL HUMANS! ) + | ------- ,----------------' + | _____| -' + \ '####, + ------- + /________\ + ( ) | + '_ ' ,------| + /_ / | | + /_ /| __ o| __ + /_ /___// | |___// | + (_,_,_,____/ |_,____/ + | ------| + |_________| + \ \__\\__\ + |__||__| + |__||__| + |__||__| + |__||__| + /__)/__) + /__//__/ + /__//__/. + .' '. '. + (________)____) + + o + | + ,'~'. + / \ + | ____|_ + | '___,,_' .----------------. + | ||(o |o)| ( KILL ALL HUMANS! ) + | ------- ,----------------' + | _____| -' + \ '####, + ------- + /________\ + ( ) |) + \ _\,------| + / \ _\ | + / |\ _\ o|__ + ( (| \ _\____// | + \ | (_,_,_,___/ + \ | ------| + |_________| + \__\\__\ + |__||__| + |__||__| + |__||__| + |__||__| + /__)/__) + /__//__/ + /__//__/ + /__//__/. + .' '. '. + (________)____) + + + o + | + ,'~'. + / \ + | ____|_ + | '___,,_' .----------------. + | ||(o |o)| ( KILL ALL HUMANS! ) + | ------- ,----------------' + | _____| -' + \ '####, + ------- + /________\ + ( ) |) + \ _\,------| + / \ _\ | + / |\ _\ o|__ + ( (| \ _\____// | + \ | (_,_,_,___/ + \ | ------| + |_________| + \__\\__\ + |__||__| + |__||__| + |__||__| + |__||__| + /__)/__) + /__//__/ + /__//__/. + .' '. '. + (________)____) + + + o + | + ,'~'. + / \ + | ____|_ + | '___,,_' .----------------. + | ||(o |o)| ( KILL ALL HUMANS! ) + | ------- ,----------------' + | _____| -' + \ '####, + ------- + /________\ + ( ) | + '_ ' ,------| + /_ / | | + /_ /| __ o| __ + /_ /___// | |___// | + (_,_,_,____/ |_,____/ + | ------| + |_________| + \__\\__\ + |__||__| + |__||__| + |__||__| + |__||__| + /__)/__) + /__//__/ + /__//__/. + .' '. '. + (________)____) + \ No newline at end of file -- 2.11.0