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 937213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:26:26+00:00 2026-05-15T21:26:26+00:00

in my current tool there is a colored box with some numbers in it.

  • 0

in my current tool there is a colored box with some numbers in it. The backcolor of the box is defined by some sort of list but can also be altered by the user. The forecolor (== fontcolor of the numbers) cannot, and i want to make sure that the user can always read the numbers, so i´d like to adjust the forecolor of the numbers anytime the backcolor changes.

Atm i use code like this:

if(Math.Abs(foreColor.GetBrightness() - backColor.GetBrightness()) <= 0.5f)
{
    if(foreColor.GetBrightness() > 0.5f)
    {
       foreColor = Color.Black;
    }
    else
    {
       foreColor = Color.White;
    }
}

but that is only a workaround for the problem, there are quite a lot of colors (mostly yellows) leading to a bad to read display. Anyone touched a similar problem and found a good solution?

  • 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-05-15T21:26:27+00:00Added an answer on May 15, 2026 at 9:26 pm

    For each color component (assume a range of [0, 255] per component), if it’s below 128, saturate it to 255; otherwise make it zero:

    fg.r = bg.r < 128 ? 255 : 0;
    fg.g = bg.g < 128 ? 255 : 0;
    fg.b = bg.b < 128 ? 255 : 0;
    

    This will essentially place the foreground color as far into the octant opposite the background color as possible.

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

Sidebar

Related Questions

Is there a tool that suggests different color combinations based on current css. Also
On my .NEt projects I'm used to the tool called ReSharper but my current
I want to get list of methods in current file, when my tool is
Other than cx_Freeze , are there any other current maintained tool suites to generate
Is there a good tool that can help to reverse engineer Java classes to
Is there any .NET performance profiling tool out there that I can attach to
There's a very powerful CLI tool - wget . But it seems like it
My current web development tool is Spring 3, I've used Hibernate before, I'm actually
Are there any tools available to monitor all current IIS requests on a server?
I have a build system tool that is using getcwd() to get the current

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.