views:

13

answers:

1

Dear SO family,

I have created an iframe which contains the label, "powered by MyWebsite.site" The "iframe itself" accepts arguments, so other webmasters may customize the appearance of it.

The problem is that since the background of the iframe could be customized, anyone can "vanish" the "powered by MyWebsite.site".

So what option do i have? How should i dynamically change the label color depending on any background?

A: 

Assuming you have access to the background color (in hex; e.g. #ff0000) defined by the webmaster, you should be able to invert the color using an algorithm such as the one that follows. The given algorithm converts the hex color value to RGB. Then it subtracts each component of the RGB value from 255, which yields the inverse. The inverted RGB value is then converted back into a hex color value. Apply the inverted hex color value to the "powered by..." text and you should be all set.

http://www.codingforums.com/archive/index.php/t-47335.html

Note that this calculation can be done directly in hex, but that may be a little more difficult to comprehend (depending on how your mind "thinks" about these things).

mcliedtk