Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8881251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:18:24+00:00 2026-06-14T20:18:24+00:00

Possible Duplicate: Distance between colours in PHP I want to detect if a RGB

  • 0

Possible Duplicate:
“Distance” between colours in PHP

I want to detect if a RGB value is a certain shade of pink. I am unsure of how to proceed with this since there doesn’t seem to be a range of RGB or hex values that follow a linear order for pink (one shade of pink is 255, 182, 193; #FFB6C1, while another is 238, 162, 173; #EEA2AD). Do you have any idea of what to do, assuming I know the beginning and ending RGB/hex values of my range?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:18:26+00:00Added an answer on June 14, 2026 at 8:18 pm

    It looks fairly linear to me. However, you need to understand a bit of color theory.

    I hope you don’t mind me including a simple refresher of color theory here before answering your question. But it helps in understanding or formulating any solution.

    First, I’m sure most will remember the color wheel they learned in kindergarten:

                                              Red
           Red                        Orange   |   Purple
            |                                \_|_/
           _o_        ---------->             _o_
          /   \                              / | \
      Yellow   Blue                   Yellow   |   Blue
                                             Green
    

    Well, we need to modify it a bit. Because it turns out that Red and Blue are not really primary colors since you can get red by mixing Magenta with Yellow and you can get Blue by mixing Cyan with a bit of Red. So The modified color wheel uses printing colors: CMY:

            Magenta
         Red   |   Blue
             \_|_/
              _o_
             / | \
      Yellow   |   Cyan
             Green
    

    This is basically the HSV color space (with S usually plotted going from the center to the edge of the wheel and V not plotted at all but usually can be changed by a slider). It is derived from printing colors CMY. So how can this help us with screen colors RGB?

    Well, if you look carefully at it you’ll notice that it is actually a composite of both printing and screen color space. It actually depicts the relationship between CMY and RGB:

            Magenta                 Magenta
         Red   |   Blue                |           Red     Blue
             \_|_/                     |              \_ _/
              _o_            ==       _o_       +       o
             / | \                   /   \              |
      Yellow   |   Cyan         Yellow    Cyan          |
             Green                                    Green
    

    So, any RGB color can be understood by understanding this color wheel. For example, there is no Yellow in RGB. But notice that Yellow is the opposite of Blue. So, to get Yellow you subtract blue from a color:

    rgb(100,80,10)  is a "yellowish" version of rgb(100,80,120)
                ^                                           ^
    

    Once you understand this color wheel working with RGB values makes more sense. With enough practice you can compose and edit colors directly in #rrggbb syntax without consulting a color chart.

    So, to answer your question. Say your target shade of pink is:

    rgb(255,182,193)
    

    We know two things about the color “pink”:

    1. We percieve it as a kind of Red. So it makes sense that the target color has high Red value (in fact it is maximum).

    2. We percieve it as a very light Red. So it makes sense that the non-Red components are also quite high (both above 150).

    So, to get shades close to your target color we need:

    1. R value significantly higher than G or B.
    2. All values to be quite high (above 150 or so).

    By this definition we can identify pink as:

    // Pseudo code:
    
    is_pink (R,G,B) {
        return R > 200 &&  // make sure R is high
               G > 150 &&  // make sure G & B are relatively high
               B > 150 &&
               R > G &&    // make sure G & B are not higher than R
               R > B;
    }
    

    We can add another condition to reject “pink” that is slightly bluish or greenish by making sure that G & B are fairly similar:

    // Pseudo code:
    
    is_pink (R,G,B) {
        return R > 200 &&
               G > 150 &&
               B > 150 &&
               R > G &&
               R > B &&
               abs(G-B) < 20; // make sure it's neither bluish or greenish
    }
    

    You can tweak the values 200, 150 and 20 to suit your taste of pinkishness but you’ll see that if we apply the above function to both your test colors (255,182,193) and (238,162,173) they’ll both be identified as “pink”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Distance between geopoints I have some latitudes and longitudes and i need
Possible Duplicate: Get the distance between two geo points distanceTo(Location dest) or distanceBetween(double startLatitude,
Possible Duplicate: Fastest Way to Find Distance Between Two Lat/Long Points I have locations
Possible Duplicate: Detect inside Android Browser or WebView i want to detect whether the
Possible Duplicate: How do I calculate distance between two latitude longitude points? How do
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: How can I convert a list<> to a multi-dimensional array? I want
Possible Duplicate: How to do the vector of sets in C++? I want to
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: check whether internet connection is available with C# I just want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.