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

how do you print on top of images?

Started by TheEDel, 03 May 2014 - 07:08 PM
TheEDel #1
Posted 03 May 2014 - 09:08 PM
I have been trying to print words on top of pictures that I have loaded with the paint utils api.

this is what I have tried

paintutils.drawImage(paintutils.loadImage("test"),1,1)
print("hello")

this is the out come

http://imgur.com/IwsB19L
(the word hello is printed beneath the picture not where i want it to be)

I was wondering why the text doesn't print over top at the very top of the screen as well as how can I make the text do that.
Yevano #2
Posted 03 May 2014 - 10:02 PM
Use term.setCursorPos before calling print to set the cursor position to 1 character above the image.


local imageX, imageY = 5, 5
term.setCursorPos(imageX, imageY - 1)
print("hello")
paintutils.drawImage(paintutils.loadImage("test"), imageX, imageY)

The reason why it doesn't print at the top is because the call to paintutils changes the cursor position and does not reset it.
Edited on 03 May 2014 - 08:03 PM
Bomb Bloke #3
Posted 04 May 2014 - 02:33 AM
That is to say, paintutils doesn't "draw images" so much as it writes space characters to the screen whilst changing the text background colour as it goes.
TheEDel #4
Posted 04 May 2014 - 07:09 PM
Use term.setCursorPos before calling print to set the cursor position to 1 character above the image.


local imageX, imageY = 5, 5
term.setCursorPos(imageX, imageY - 1)
print("hello")
paintutils.drawImage(paintutils.loadImage("test"), imageX, imageY)

The reason why it doesn't print at the top is because the call to paintutils changes the cursor position and does not reset it.

thanks! also how do I know which one will be in front (the picture or the text) and how would you change which is in the front/back)
CometWolf #5
Posted 04 May 2014 - 07:15 PM
Which ever is written last will be in front, as the screen is only one layer.
Bomb Bloke #6
Posted 04 May 2014 - 11:28 PM
Though if you check out term.setBackgroundColor() in the term API, you can probably work out how to get the effect you want anyway.