# README
Description
Ascii-art is a program that receives a string as an argument and displays the string in a graphic representation using ASCII.
Authors
Features
Supports: 1.color 2.output 3.justify 4.fs
Usage: how to use the program
Assuming the current working directory, is set to the repository's root:
-
Displaying the ASCII graphics of the text
Hello
using the defaultstandard
banner:ascii-art-color$ go run . "Hello" _ _ _ _ | | | | | | | | | |__| | ___ | | | | ___ | __ | / _ \ | | | | / _ \ | | | | | __/ | | | | | (_) | |_| |_| \___| |_| |_| \___/ ascii-art-color$
-
Displaying the ASCII graphics of the text
Hello
with theshadow
banner:ascii-art-color$ go run . "Hello" shadow _| _| _| _| _| _| _|_| _| _| _|_| _|_|_|_| _|_|_|_| _| _| _| _| _| _| _| _| _| _| _| _| _| _|_|_| _| _| _|_| ascii-art$
-
Displaying the ASCII graphics of the text
Hello
with thethinkertoy
banner:ascii-art-color$ go run . "Hello" thinkertoy o o o o | | | | O--O o-o | | o-o | | |-' | | | | o o o-o o o o-o ascii-art-color$
-
Write the ASCII graphics of the text
Hello
with theshadow
banner to the output fileoutput.txt
:ascii-art-output$ go run . --output=output.txt "Hello" shadow ascii-art-output$ cat output.txt _| _| _| _| _| _| _|_| _| _| _|_| _|_|_|_| _|_|_|_| _| _| _| _| _| _| _| _| _| _| _| _| _| _|_|_| _| _| _|_| ascii-art-output$ ls
-
You can use specify how you want a text to be colored.
ascii-art-color$ go run . --color=red "hello world" ``` _ _ | | | | | | | | | | | |__ ___ | | | | ___ __ __ ___ _ __ | | __| | | _ \ / _ \ | | | | / _ \ \ \ /\ / / / _ \ | '__| | | / _` | | | | | | __/ | | | | | (_) | \ V V / | (_) | | | | | | (_| | |_| |_| \___| |_| |_| \___/ \_/\_/ \___/ |_| |_| \__,_|
-
Here is an example output of our program supporting multiple colors.
Implementation details: algorithm
-
Download the three banner files (
shadow
,standard
, andthinkertoy
) to a subdirectory,banners
, in the repository root.After this task, we expect the following file structure:
ascii-art banners shadow.txt standard.txt thinkertoy.txt
-
Create a
main.go
program, that parses commandline arguments in the following format:go run . "Hello"
: The first argument is the text whose graphics is to be displayed.go run . "Hello" standard
: The first argument is the text whose graphics is to be displayed, while the second argument selects any of the given graphics files to use (must be one ofshadow
,standard
, andthinkertoy
).
-
Once done parsing the commandline args, the
main.go
file should also split the input string (the string to be displayed) into lines, then feed each line separately to a line graphics drawing function,drawln
, that takes the line of string to be drawn, alongside the banner format, either of (shadow
,standard
, andthinkertoy
). This should be done in a separatedraw
function, defined in themain.go
file.See task 5 below for the implementation details of the function,
drawln
. -
Create and implement a module,
graphics
, that given a specific banner file, either of (shadow
,standard
, andthinkertoy
), reads the banner file following the banner file format to generate a map of the ASCII characters to their graphical string representation. This map should be such that, the keys are the ASCII characters, while the values are the graphic representation of the ASCII characters, that is:key value H _ _ | | | | | |__| | | __ | | | | | |_| |_|
T _______ |__ __| | | | | | | |_|
Given the Banner Format
- Each character has a height of 8 lines.
- Characters are separated by a new line \n.
We come up with the following algorithm to read the file:
Open file map <- new map Start with the space character as the first ASCII character current_ascii_character <- ' ' while not at end of file: Read the character separating newline graphics [8]string <- Read the next 8 lines containing the graphics map[current_ascii_character] <- graphics current_ascii_character++ Close the file
-
Now to draw the graphics for a line of text, the
drawln
function follows the following steps:for each graphics line from n=0 to n=7 do; for each character in line do; print the nth graphics line, i.e. graphics[n] print a newline to end the current line