This might be more of a general programming question but I am hoping someone here can help. I am trying to find a way to check if a pixel is on or off. Some kind of boolean function. Is their already a function in the lib files that accomplishes this? If so, can you direct me to it? Maybe someone here has created their own function? I am working on a function in C that makes text on the matrix appear to dissolve from the screen. It does this by setting the RGB of the pixels within the area of the font to 0, 0, 0 (off). Its slow as is due to it also trying to turn off the pixels that are already off. Hoping to speed it up by creating or using a function that returns TRUE if a pixel is already off. A bit of a noob here. Any help appreciated.
I asked this question a while ago. The answer I got was no, it is not possible. A work around is to keep track of the LED display in a 2D array and every time you set the screen, you keep the 2D array up to date.
I have a function that I call to set a pixel. It keeps the ScreenArray (my 2D array) up to date. Then I can query the ScreenArray and do whatever I want.
#Screen array is a copy of the matrix light layout because RGBMatrix is not queryable.
ScreenArray = ([[]])
ScreenArray = [[ (0,0,0) for i in range(HatWidth)] for i in range(HatHeight)]
def setpixel(x, y, r, g, b):
global ScreenArray
if (CheckBoundary(x,y) == 0):
TheMatrix.SetPixel(x,y,r,g,b)
ScreenArray[y][x] = (r,g,b)