This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
billysback's profile picture

Visual - Visualise any string, any length in to an image!

Started by billysback, 05 January 2013 - 03:19 AM
billysback #1
Posted 05 January 2013 - 04:19 AM
This is a little program which takes a string and creates an image, usually repetitive or pattern-like, based off of the string, use the same string and you get the same picture every time, any changes to the string could bring up an entirely different image however :P/>

Here's the pastebin:
http://pastebin.com/dYq0nJbr

Here's an example image (this is "hello")
Spoiler

Usage is: (visual is whatever you called the program)

visual <data>
example:

visual hello

If you want any other examples of strings I will be happy to post them here, or give examples of cool strings.
This was just a little test project of mine to see if I could visualize data, I might be taking this further to make some sort of game, I'll see what I can do. Either way, feel free to use the code for this in whatever you want, just thought I would share this :)/>
wilcomega #2
Posted 05 January 2013 - 04:41 AM
very cool, have you got a image reader for it so it can be converted back into a string?
kornichen #3
Posted 05 January 2013 - 04:53 AM
very cool, have you got a image reader for it so it can be converted back into a string?

That would be interesting :D/>
billysback #4
Posted 05 January 2013 - 04:55 AM
you mean take any image and turn it into a string?
hmmmm…. not really sure that would work as characters share colours…
Orwell #5
Posted 05 January 2013 - 05:22 AM
I've seen code like this very often in your programs:

while index > 16 do index = index - 16 end

Do you know about the modulo operator?

index = (index-1)%16+1
It's equivalent in length in this particular case (whilst modulo is more efficient). But in the case of your encryption program you posted once, it would've made stuff a hell of a lot simpler.

There's more stuff like that, but I shouldn't criticize a published program. I just wanted to make sure that you know modular math.

I'm not sure about the purpose of this program, but it looks funny. :P/>
billysback #6
Posted 05 January 2013 - 05:24 AM
Do you know about the modulo operator?

index = (index-1)%16+1
There's more stuff like that, but I shouldn't criticize a published program. I just wanted to make sure that you know modular math.
no… I'm presuming it's the "%", in what way does it work?
n-1%17 returns a value less than 17 excluding 17 in a way that is similar or the same way to reducing it by that amount each time?


and its not exactly meant to have a "purpose" other than to look nice :P/>
nutcase84 #7
Posted 05 January 2013 - 05:27 AM
This is sweet. Great job.
EDIT: when i try to run this, it crashes the computer.
Orwell #8
Posted 05 January 2013 - 05:33 AM
Do you know about the modulo operator?

index = (index-1)%16+1
There's more stuff like that, but I shouldn't criticize a published program. I just wanted to make sure that you know modular math.
no… I'm presuming it's the "%", in what way does it work?
n-1%17 returns a value less than 17 excluding 17 in a way that is similar or the same way to reducing it by that amount each time?


and its not exactly meant to have a "purpose" other than to look nice :P/>
Actually, it just gives you the remainder of the division between the first and the second number. Thus:

11%4 == 3
17%5 == 2
(18-1)%17+1 == 2