Find and Replace: Vision Component Colors

I rewrote @justinedwards.jle's example with an eye for performance; basically avoiding a lot of unnecessary allocations of new Color objects:

findColor = system.gui.color(0, 0, 0)
replaceColor = system.gui.color(255, 255, 255)

def colorFinder(component):
	for component in component.getComponents():
		if component.background.rgb == findColor.rgb
			component.background = replaceColor
		if component.foreground.rgb == findColor.rgb
			component.foreground = replaceColor
		colorFinder(component)

parentWindow = system.gui.getParentWindow(event)
colorFinder(parentWindow)
4 Likes