Posted 28 October 2015 - 10:40 AM
The better way to print pictures
As it says™. This tutorial is simply making it faster to print pictures, as it makes a significant difference. This can be used for animations, huge rendering and more.
Normally printing pictures
Now, as a lot of people normally print pictures they might do something like this:
after testing this for speeds, it got 0.1 seconds. i know its not really much, but it can do better if you're printing multiple pictures, or printing to a monitor. if its 2 pictures, that would get 0.2 seconds. 10 would be 1 second. with the next yet quite bigger code, its easier to get better speeds.
all math aside, it does do the trick. with some tests, this got 0.05 seconds each time.
remember i said 10 pics would be a second? now it's a half second. this will again help you people print crazy huge pictures on crazy huge monitors.
what its doing in order:
As it says™. This tutorial is simply making it faster to print pictures, as it makes a significant difference. This can be used for animations, huge rendering and more.
Normally printing pictures
Now, as a lot of people normally print pictures they might do something like this:
pic = paintutils.loadImage("somerandompicture")
paintutils.drawImage(pic,1,1)
after testing this for speeds, it got 0.1 seconds. i know its not really much, but it can do better if you're printing multiple pictures, or printing to a monitor. if its 2 pictures, that would get 0.2 seconds. 10 would be 1 second. with the next yet quite bigger code, its easier to get better speeds.
loadedfile = "Your Picture Here™"
function load(file) --thanks valithor and bomb bloke for teaching me this ;)/>/>
local out = {}
for line in io.lines(file) do
out[#out + 1] = line
end
return out
end
file = fs.open(loadedfile,"r")
lines = load(loadedfile)
space = ""
for i = 1,#lines do
for i = 1,#lines[i] do
space = space.." "
end
term.blit(space,space,lines[i])
write("\n")
space = ""
end
i know that's 10 times bigger, but it will do. it's only over ~390 bytes compared to ~140 bytes.all math aside, it does do the trick. with some tests, this got 0.05 seconds each time.
remember i said 10 pics would be a second? now it's a half second. this will again help you people print crazy huge pictures on crazy huge monitors.
what its doing in order:
- loading and splitting a file into its lines
- calculating the length of each line, to fit the spaces making colour
- blitting each line, makes it faster to print a line
- nothing else, it didn't really do much in the first place
Edited on 28 October 2015 - 09:42 AM