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

Help with putting an image on an monitor.

Started by dom123, 03 January 2014 - 02:01 PM
dom123 #1
Posted 03 January 2014 - 03:01 PM
I have been researching for the last 6 hrs are you able to scroll an image on an advanced monitor?

– I want to draw a picture (Minecraft Bee from Forestry Mod) in the advanced computer paint program and i want to display this on a *6X8 monitor and i would like to scroll the image to the left as if the bee is moving to the left I want to scroll this across multiple screens. (I think this would take multiple computers)

If you could provide any help that would be great I don't even know where I would start with coding this.
ikke009 #2
Posted 03 January 2014 - 03:22 PM
I think the easiest way to do this is to make a function to draw the image that allows an x offset
something like this

function draw(offset)
term.setCursorPos(offset,1)
write(" ")
term.setCursorPos(offset+1,2)
write(" ")
...etcetera
end

for i=1,width do draw(i) end
as for the multiple monitor thing, include something like this

if offset+imagewidth > monitorwidth then
drawOnSecondMonitorWithOffset(monitorwidth-offset-imagewidth)
--(not sure if this would work but i think so)

Needless to say you will not be able to copypaste any of that, but i hope it gives you an idea of what to do.. and yes, all the variables are made up, i hope it's clear enough what i mean with it :P/>
maybe someone else has more time to write out something more detailed but i encourage you to try and do this with as little help as possible, for the sake of learning how to actually do this..
Imprivate #3
Posted 03 January 2014 - 08:31 PM
Paintutils API lets you specify the coordinates to display your image. Syntax:
paintutils.drawImage(table image handle, number x-position, number y-position)
A full 8x6 monitor is 82x40 pixels, so:

local x = 1
local y = 1
repeat
monitor = peripheral.wrap("right")
term.redirect(monitor) -- Redirects everything to be displayed on monitor instead of the computer
img = paintutils.loadImage("ImageFileNameHere")
paintutils.drawImage(img, x, y)
x = x+1
sleep(0.5)
term.clear()
term.restore() -- Stops redirecting to monitor
until x == 82
this should display the image for 0.5 seconds (change if you want), then move it one pixel to the right. Once it starts disappearing off the right side of the monitor, you need a second computer to kick in and start displaying the image from its first pixel. I havn't tried this at all so don't expect anything to work :)/> Hope this isn't too vague!