had some bad recursion in the function, fixed with a while loop
determines if new bg color is "dark" or "bright" text and buttons invert color when bg color is too bright