Saturday 15 June 2013

Overlay text files on top of each other and output to another text file in C++? -



Overlay text files on top of each other and output to another text file in C++? -

i busy writing programme constructing minions (from despicable me) using ascii of minions in text file. want able have user input features he/she wants minion have. then, this, programme "decorate" minion putting text files minion he/she wanted.

for example:

the user inputs wants tall minion 1 eye , big smile - have features of minions created in text files parts missing minion. want "overlay" tall minion text file on top of 1 eyed minion text file, on top of big smiling minion text file in end creates total minion.

i wondering if possible do? build minions or have hard way changing format of text files add together in features using fstream.

this link these minion ascii from: http://textart4u.blogspot.com/2013/08/minion-what-text-art-despicable-me.html

ignore issue of minions of different dimensions moment. assuming have character represents transparency (or not-part-of-the-feature characters, e.g. white space), can assign each feature depth, iterate on selected feature files background foreground, , write each non-transparent character in right position ongoing minion text file.

here's rough pseudo code assumes each file has same number of lines.

class="lang-none prettyprint-override">write minion base of operations (most background) output file. each feature file, background foreground: seek origin of output file. each line in feature file / output file: extend output file's line match feature file's line if necessary. each character in line of feature file / output file: if feature file's char not transparent: overwrite current char in output file current char in feature file.

if not flexible enough, can assign each character of feature file depth, , iterate on feature files in order, overwriting current output file's character if feature file's character closer foreground. you'd need encode depth somehow -- using corresponding depth file obvious way.

the tricky part might supporting minions of different dimensions. handle that, may plenty specify vertical/horizontal offsets every feature / minion body type combination, , utilize adjust write feature in ongoing output file. alternatively, may easier duplicate each feature file appropriate modifications create fit given minion body type. both of these methods require manual grunt-work, if don't have worry many body types, these simple methods preferable more complicated flexible methods.

c++ text-files fstream

No comments:

Post a Comment