I am surprised by how great TMatrix's output is, the gradient looks amazing, and I think another good feature would be giving more control on which characters are shown.
The idea comes from will8211/unimatrix and the implementation there is actually very simple, there are two command-line parameters, one for predetermined charsets and other for custom characters. I believe even just one of the two strategies would already be a good additioon to TMatrix, and sooner or later I'll probably implement this to some extent even if just for me to use it, so I may be able to send a PR.
Then for the charsets option just concatenate the characters for each specified Charset into a Variable with all possible characters. And to make things even simpler, the custom characters passed through the parameter are saved as one of the charsets:
# "-l" option has been used
if args.character_list:
chars = ''
for letter in args.character_list:
try:
chars += char_set[letter]
except KeyError:
print("Letter '%s' does not represent a valid character list."
% letter)
exit()
And just pick a random character from the all-possible-characters variable to display:
@staticmethod
def get_char():
"""
Returns a random character from the active character set
"""
return chars[randint(0, chars_len)]
This has the advantage of specifying not only which characters are available but also how common or rare each character is.
I'd probably use a lambda for the "m" charset and maybe using a lambda or something to generate charsets in a cleaner way
In Ruby (which is my go-to language) for instance, I can do stuff like this:
I am surprised by how great TMatrix's output is, the gradient looks amazing, and I think another good feature would be giving more control on which characters are shown.
The idea comes from will8211/unimatrix and the implementation there is actually very simple, there are two command-line parameters, one for predetermined charsets and other for custom characters. I believe even just one of the two strategies would already be a good additioon to TMatrix, and sooner or later I'll probably implement this to some extent even if just for me to use it, so I may be able to send a PR.
The implementation on Unimatrix is pretty simple:
First there's an Object/Hash/etc with the predefined charsets:
Then for the charsets option just concatenate the characters for each specified Charset into a Variable with all possible characters. And to make things even simpler, the custom characters passed through the parameter are saved as one of the charsets:
And just pick a random character from the all-possible-characters variable to display:
This has the advantage of specifying not only which characters are available but also how common or rare each character is.
I'd probably use a lambda for the "m" charset and maybe using a lambda or something to generate charsets in a cleaner way
In Ruby (which is my go-to language) for instance, I can do stuff like this:
So putting that together with my love for hackish stuff, I'd most likely consider taking arguments formatted as something like:
...so I could do this kinda madness:
Or the slightly more readable and less quirky:
Pretty neat for less than 10 lines of code, if I do say so myself... And I think this covers pretty much everything I might want.