Getting the average color lightness of an area in a GUI?

The title may be slightly confusing, so I will try to explain it the best I can.

Essentially, I have a GUI set up like this:

I have a bar at the bottom:

image

I need to find out if the colors in the area around the bar are lighter or darker. If they are lighter then the bar will change to black. If they are darker then the bar will change back to white.

This is a simple concept that I see in a lot of new phones that use a home bar instead of a button.


What have I tried?

Because the system has different frames that constantly change and all have potentially different colors, I need a way to just get the color of a certain area of the actual ScreenGui and not just a frame.

I have looked into forums about doing things like ScreenGui:GetPixelColor() or things similar, however, they have not been implemented into Roblox and likely never will.

I also thought about looping through every visible frame and finding the one with the highest ZIndex, however, it is not very efficient and doesn’t work with image-based GuiObjects.

If you have any suggestions they would be greatly appreciated!

I guess I also forgot to mention that the “home bar” is not included in this calculation. I want to get everything under the “home bar”.

An equivalent might be something like

ScreenGui:GetAreaColor(
    startCorner: Vector2,
    endCorner: Vector2,
    ignoreObject: GuiObject
)

Obviously this is not a thing, but if it were this would be what I want to do.

you can loop through the whole guis descendants (except the home bar), put their colors in a table then use this function, and apply it to the homebar

for images this wouldnt work but what you could do is get the average color of the picture (from a website) then put it as the imagelabels color

1 Like

didnt notice that part, would you could do is use GetGuisAtPosition, loop through them, check which are in the mobile gui, check for zindex then apply the color

2 Likes

Not exactly the solution I hoped for, but I suppose sacrifices will need to be made to get this to work, as Roblox doesn’t have a good feature to make this work without excessive workarounds.

Thank you for the suggestion!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.