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

  • Home
  • SEARCH
  • 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

My current setup.py script works okay, but it installs tvnamer.py (the tool) as tvnamer.py
I've been using WatiN as a testing tool for my current project. Besides the
I am working on an in-house tool for interfacing to a database. My current
My current development project has two aspects to it. First, there is a public
Current, I've got a stored procedure that has a main goal of doing a
My current preferred C++ environment is the free and largely excellent Microsoft Visual Studio
My current project is in Rails. Coming from a Symfony (PHP) and Django (Python)
My current view is no, prefer Transact SQL stored procedures because they are a
My current place of employment is currently in a transition, new ownership has taken
Why does switch ([document currentTool]) { case DrawLine: NSBezierPath * testPath = [[NSBezierPath alloc]init];

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.