javascript - Text to ASCI Font generator -


and sorry vague question title. please read on mental impression of thoughts.

i want create program takes string input , outputs asci images

example- string "say hi"

output:

-------------------------------------------------------------------------------|      ------      /-------\     |||     |||   ------                             |      ||        |||     |||    |||     |||   ||                                 |      \\        |||__ __|||    |||__ _ |||   \\                                 |         ==\\    ||| _ _ |||        |||         ==\\                             |            ||    |||     |||        |||            ||                            |       ------     |||     |||        |||       ------                             | -------------------------------------------------------------------------------|  --------------------------------------------------------------------------------|                                                                                 |                      |||    |||  [=========]       |||                          |                       |||_ __|||      |||           |||                          |                      |||__ _|||      |||           |||                          |                      |||    |||      |||           |||                          |                      |||    |||      |||           ___                          |                       |||    |||  [=========]       |__|                         |  --------------------------------------------------------------------------------| 

possible approach achieve this.

1) (naive approach) convinced myself creating 2-d character array possible characters, store them, , upon entering input string check individual characters , cout stored 2-d array respective character, till reach string's end.

for example: store char as.  char[][] =    .----------------.  | .--------------. | | |      __      | | | |     /  \     | | | |    / /\ \    | | | |   / ____ \   | | | | _/ /    \ \_ | | | ||____|  |____|| | | |              | | | '--------------' |  '----------------'  possible logic approach is. foreach(str[i].....str [n])    identifycharacter();    identifythecorrespondingcharacter2-darray();       iteratethrougheachrowintheidentifiedarray.          printeachrowin2-darryinnewline  same goes b-z , 0..9 

lets not talk efficiency , optimality, above approach far far away optimal, not scalable, if @ all, if want generate fonts of different sizes , all, approach surely won't help.

2)bombarded enough confusions, , non-efficient-logic, not knowing call them, searched "text asci font generator", tried web , browsing first few links, got me towards similar project on git.

https://github.com/patorjk/figlet.js

which appeared scalable, , looks preety cool

http://patorjk.com/software/taag/#p=display&f=graffiti&t=type%20something%20

what meant solution is, possible if use specific language, might make job easier, saying. i'm ready learn new tool this.

there, want create program outputs asci images netered string, same 1 in link provided.

the idea create asci garden, user enters string , generate asci images, furthermore provide them option choose, if user enters string "house", create asci house, , not asci clone of string house. hope understand i'm trying say.

a house         /\         /  \               |....|       |  []|       ------ 

well, not awesomely innovative brilliant breakthrough, want free time, , motivation learn new tools, if not possible present arsenal. (c++, php, javascript).

please let me know if have sincere suggestions this, , have courtesy let me know if question not appropriate here, i'll happy move it. i'm not sure appropriate tags question belongs, i'm in suggestions.

thanks

you along these lines:

var letters = {      : [          ' /-------\\ ',          '|||     |||',          '|||__ __|||',          '||| _ _ |||',          '|||     |||',          '|||     |||'      ],      s : [          ' ------',          ' ||    ',          ' \\\\    ',          '   ==\\\\',          '     ||',          '------ '      ],       y :  [          '|||     |||',          '|||     |||',          '|||__ _ |||',          '    |||    ',          '    |||    ',          '    |||    '      ]  };    var text = "say";  var lines = ['', '', '', '', '', ''];    for(var = 0; < text.length; i++){    // each letter,      var letter = text[i].tolowercase();    // current letter,      for(var j = 0; j < 6; j++){              // each line letters high,          lines[j] += letters[letter][j] + '   ';// add current line result.      }            // spacer between letters ^  };  document.getelementbyid("result").innerhtml = lines.join("\n"); // output result.
<pre id="result"></pre>

you'd have add checks check non-existant characters, not mention adding rest of characters manually, idea.

keep in mind "\\" in js translates "\" in output. you'll need double backslashes, because they're escaping themselves.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -