Jump to content




to find out how to get informations about a pixel

help

7 replies to this topic

#1 Jummit

  • Members
  • 306 posts
  • LocationJulfander Squad Studio

Posted 05 August 2017 - 11:10 AM

I am searching for a function to get the background color, the text color and the string which is on the pixel. Is there a function that does this? In the paintutils api is nothing...

Edited by Jummit, 05 August 2017 - 11:11 AM.


#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 05 August 2017 - 05:19 PM

It is not possible to know what is displayed without recording that information when it is drawn.

#3 Dog

  • Members
  • 1,179 posts
  • LocationEarth orbit

Posted 05 August 2017 - 05:28 PM

I'm not sure when it was added, but IIRC CC 1.79 (and possibly earlier?) have term.getTextColor(x, y) and term.getBackgroundColor(x, y) but no way to find out which character is on screen. As KingofGamesYami said, you'll need to record what's written to screen (when it's drawn) if you want to know what characters are where on screen.

EDIT: Correction - as noted below, getTextColor and getBackgroundColor don't use x,y coords.

Edited by Dog, 06 August 2017 - 12:17 AM.


#4 Jummit

  • Members
  • 306 posts
  • LocationJulfander Squad Studio

Posted 05 August 2017 - 05:34 PM

Thanks for the information, guys! Would be very usefull to have a a function for this, like term.getPixelInformation or would it be paintutils.getPixelInformation?

#5 The Crazy Phoenix

  • Members
  • 136 posts
  • LocationProbably within 2 metres of my laptop.

Posted 05 August 2017 - 08:06 PM

If it did exist, it would be in the term API.

#6 Lupus590

  • Members
  • 2,029 posts
  • LocationUK

Posted 05 August 2017 - 08:07 PM

View PostDog, on 05 August 2017 - 05:28 PM, said:

I'm not sure when it was added, but IIRC CC 1.79 (and possibly earlier?) have term.getTextColor(x, y) and term.getBackgroundColor(x, y) but no way to find out which character is on screen.

Added in 1.74, doesn't take an screen coordinate as an argument, gives the current colour (the one most resently set with the equivulent set function). [source - the wiki]

#7 Dog

  • Members
  • 1,179 posts
  • LocationEarth orbit

Posted 05 August 2017 - 11:20 PM

View PostLupus590, on 05 August 2017 - 08:07 PM, said:

View PostDog, on 05 August 2017 - 05:28 PM, said:

I'm not sure when it was added, but IIRC CC 1.79 (and possibly earlier?) have term.getTextColor(x, y) and term.getBackgroundColor(x, y) but no way to find out which character is on screen.

Added in 1.74, doesn't take an screen coordinate as an argument, gives the current colour (the one most resently set with the equivulent set function). [source - the wiki]

Ahh, that makes sense. Thanks, Lupus :)

#8 Lupus590

  • Members
  • 2,029 posts
  • LocationUK

Posted 06 August 2017 - 07:09 PM

@OP It can be done if it's supported by the screen buffer that you are using.

I would use Lyqyd's Framebuffer, but I'm a bit bias to his stuff. You should be able to read the text from the buffer like so, fair warning I haven't tested this

local buf = framebuffer.new(sizeX, sizeY, colour, offsetX, offsetY)
--# you may want to write more stuff to the buffer here
buf.write("this is an example")
buf.buffer.text[x][y] --# should give you the character at that coorodinate
buf.buffer.textColor[x][y] --# same again for the text colour (British spelling for the win)
buf.buffer.backColor[x][y] --# I would help that you would be able to figure this one out






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users