7 Replies Latest reply on Sep 25, 2006 10:46 PM by GmR

    Evaluating Color Values?

    GmR Level 1
      Is there a way to evaluate, via Actionscript, if myColor is brighter than, say #CCCCCC?

      Thanks,
      Geoff
        • 1. Re: Evaluating Color Values?
          2m Level 2
          This is a tricky one, ,first of all brightness is most of the time something that is to an extend in the eye of the beholder.

          Technicaly I'd try the following approch:

          As away the first two digits give a hexadeciaml value for the brightness of the red composit of you color the sthird and fourth for the gree and the last two for the brightness of the blue composit you can confert each pair into its value (if you don't shy away from working with hex numbers, you don't even have to convert.)

          The sum of rebBrightness, greenBrightness and blueBrightness can give you an estimate of a total brighness which can be compareed to other colors.

          Example
          the brightness of #cccccc would be in decimal 612,
          (three times cc which is 204 in decimal notation)
          the brightnes of pure red ('ff0000) would be 255;
          (ff -> 255 + 00 -> 0 + 00-> 0 = 255);
          Photoshops pure yellow orange (#f7941d) would be 424.
          (f7 -> 247 + 94 -> 148 + 1D -> 29)


          Especially with closer values and differen colors it migth not be something that is seen the same by everybody.

          Techincally this does meassure (simply put) the amount of light that your display will emit, waht you feel is brighter might diifer from that pure red and pure blue whould have the same value but most would consider the red brighter, and depending on your displays make and settings is might be, if you meassure the light with an scientific, external device...
          • 2. Re: Evaluating Color Values?
            Level 7
            "GmR" <webforumsuser@macromedia.com> wrote in message news:e4u9sd$3uf$1@forums.macromedia.com...
            > Is there a way to evaluate, via Actionscript, if myColor is brighter than, say #CCCCCC?
            >
            > Thanks,
            > Geoff

            You can't compare raw RGB numbers because different colors have greater or lesser affect on overall brightness. Blue has a minor
            affect on brightness, while green has a big impact on it. (i'm talking about VGA displays here) Here is the formula for
            calculating luminance from RGB values..

            red 30%
            green 59%
            blue 11%

            Once you calculate the luminance values of your colors you can compare those numbers.

            That formula can be used to convert color images to black and white by reading the RGB values of each red green and blue pixel, then
            setting all 3 pixels to that 'luminance' number.
            I made a demo for you to see how it works.
            http://www.kompanionkare.net/flash/color/setRGBbrightness.html

            tralfaz


            • 3. Re: Evaluating Color Values?
              2m Level 2
              Kudos to tralfaz!

              Forget my post (even if not totally wrong, the half truth isn't half as good as what tralfaz provided.)
              As one can guess from my cautios writing, I was aware that diffrent color-components might have more or less influence on overall brightness.
              I never would have guess though, that it is that much of a difference.

              Thanks again for the insight!
              • 4. Re: Evaluating Color Values?
                Level 7
                "2m" <webforumsuser@macromedia.com> wrote in message news:e4um9m$k08$1@forums.macromedia.com...
                > Kudos to tralfaz!
                >
                > Forget my post (even if not totally wrong, the half truth isn't half as good
                > as what tralfaz provided.)
                > As one can guess from my cautios writing, I was aware that diffrent
                > color-components might have more or less influence on overall brightness.
                > I never would have guess though, that it is that much of a difference.
                >
                > Thanks again for the insight!

                I know it looks wrong at first that blue only is worth 11% of brightness but that's what it says in the books. I originally learned
                that from TV repair school. It has been so long ago that I had to look it up. Here's the site that I found the formula at.
                http://nemesis.lonestar.org/reference/internet/web/color/luminance.html

                I wish I had Flash 8 so that I could play with the individual pixel values (I think it can do that?) With Flash 6 and
                colorTransform I can get something close to a color to black-and-white conversion but it's different for each image so I can't use a
                standard formula that I know of and it's not perfect.
                I.E. To get a nearly black-and-white image on this photo it needs
                RB -62
                GB -8
                BB +28
                http://members.cox.net/4my5cats/colorTransform.html

                Although it's not perfect you could manipulate the numbers in a Flash program to get some cool looking effects of starting with a
                black and white image and fading up the color. Thing is you would need to determine the correct numbers to use for each image ahead
                of time.
                tralfaz


                • 5. Re: Evaluating Color Values?
                  2m Level 2
                  Hi tralfaz,

                  this is the second time today that one of those forom Angels, always helping the others tells me that he isn't in posession of a recent Flash version, and I can't stop to wonder why taht it - actually I know, that it is none of my buisness, but i got the conviction that somebody like you helping so much others really should get a licens from adobe for free.

                  I really think about trieng to convince those guys at Adobe to cnvince them to do so, becaus you (and those others) really do make their product worth a lot more.

                  Tell me if you think I should have a try.

                  And sorry to the OP for hijacking this thread.
                  • 6. Re: Evaluating Color Values?
                    Level 7
                    "2m" <webforumsuser@macromedia.com> wrote in message news:e4vpls$7i1$1@forums.macromedia.com...
                    > Hi tralfaz,
                    >
                    > this is the second time today that one of those forom Angels, always helping
                    > the others tells me that he isn't in posession of a recent Flash version, and I
                    > can't stop to wonder why taht it - actually I know, that it is none of my
                    > buisness, but i got the conviction that somebody like you helping so much
                    > others really should get a licens from adobe for free.
                    >
                    > I really think about trieng to convince those guys at Adobe to cnvince them to
                    > do so, becaus you (and those others) really do make their product worth a lot
                    > more.
                    >
                    > Tell me if you think I should have a try.
                    >
                    > And sorry to the OP for hijacking this thread.

                    I really like the way you think my friend! It's a nice thought but I don't know if they do that. It would be great cuz for some
                    reason my wife thinks she should have the money for bills instead of Flash 8. Silly women. hehehe
                    tralfaz


                    • 7. Re: Evaluating Color Values?
                      GmR Level 1
                      I know I'm a long time getting back to this, but thanks for your help.

                      I am trying to find a way of setting my foreground colour to white, if the background colour is darker than say, CCCCCC.

                      I'm not at all familiar with hex calculations, so if anyone has some code that might handle this, I'd be a friend forever. ;-)

                      Thanks,
                      GR