Hello..
Does anyone know a method to get the current color of a pixel, without editing shell/bios/term... ?
i know i could just use tables to store the information, but how would i be able to?
could you give examples?
Thanks in Advance
get color of current pixel - Question
Started by Goof, Apr 19 2013 03:32 AM
6 replies to this topic
#1
Posted 19 April 2013 - 03:32 AM
#2
Posted 19 April 2013 - 04:44 AM
You are correct you would have to save the data to a table. Heres an example:
Basically you have a table for your column(x) and inside that you have a table for what row(y) it is. So if i had a pixel at 3,5 it would be in the third column and fifth row. To retrieve the data it would be screens[x cord][y cord][what data I want]. Assuming you want to keep track of the color of the character and the what character is displaying there you might add:
After line four before line five.
Hope this helped if you need more help just ask.
screen = {}
function pixel(x,y,char,color)
--draw the pixel
screen[x][y] = your pixel
end
Basically you have a table for your column(x) and inside that you have a table for what row(y) it is. So if i had a pixel at 3,5 it would be in the third column and fifth row. To retrieve the data it would be screens[x cord][y cord][what data I want]. Assuming you want to keep track of the color of the character and the what character is displaying there you might add:
screens[x][y]["color"] = color screens[x][y]["char"] = char
After line four before line five.
Hope this helped if you need more help just ask.
#3
Posted 19 April 2013 - 07:11 AM
Sariaz, on 19 April 2013 - 04:44 AM, said:
-snip-
local pixels = {}
function pixel(x, y, char, color)
term.setCursorPos( x, y)
local sText = char or " "
term.setBackgroundColor(color or colors.black)
write(sText)
pixels[#pixels + 1] = {}
pixels[#pixels].x = x
pixels[#pixels].y = y
pixels[#pixels].char = sText
pixels[#pixels].color = color or colors.black
end
Of course, it depends on what you are wanting to accomplish with this. I would personally use this, but if you dont want to, please use Sariaz's.
And if you really want to, you can search first if your x and y are used in the table, then overwrite that. But I will leave that to you
#4
Posted 19 April 2013 - 07:37 AM
If you want to search by coordinates use mine if you want to search by pixel you add use Engineer's. Would you agree Engineer? I could see using mine for a game to get the color and other such data about a specific block. If however, you have a game that just needs to know what pixels its made you should probably use Engineer's.
#5
Posted 19 April 2013 - 07:48 AM
Sariaz, on 19 April 2013 - 07:37 AM, said:
If you want to search by coordinates use mine if you want to search by pixel you add use Engineer's. Would you agree Engineer? I could see using mine for a game to get the color and other such data about a specific block. If however, you have a game that just needs to know what pixels its made you should probably use Engineer's.
#6
Posted 19 April 2013 - 07:55 AM
Ya you can do everything with both of ours its just some parts are easier with mine, and others are easier with yours. Example: searching by cords Me: screen[x pos][y pos] you: loop through table checking till find a match. Reverse: looking by time created you: pixels[pixel's number] me: loop through table till find a match. 
Edit: btw like your quote.
Edit: btw like your quote.
Edited by Sariaz, 19 April 2013 - 07:55 AM.
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











