Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Graphics
  4. Get Lighter / Darker color

Get Lighter / Darker color

Scheduled Pinned Locked Moved Graphics
helptutorialcsharpasp-net
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ednrgc
    wrote on last edited by
    #1

    I created a charting control for work in ASP.NET, and so far, they are thrilled. It has a bar chart, and a pie chart. Now they want a line chart (like a vertical bar). I have it working, but now they want each bar to look 3D. Each item is passed into a collection on the control. An item consists of a color and amount. The chart is built by the percentage of each item in the total of all items. Now they want the line chart (vertical bar) to have a 3D feel. I was able to get the 3D look, but I'm having a problem determining the values for the lighter and darker parts of each item. I need to figure out a lighter (and a darker) color for the passed value. For example, the bar color would be red. For the shadowed part of the bar, I need a darker red. For the top of the bar, I need a lighter color. But since each item color is being passed, I need to determine these colors on the fly. Something like GetDarkerColor(PassedColor) would be great. I just don't know how to determine these values. Any help would be greatly appreciated.

    L 1 Reply Last reply
    0
    • E ednrgc

      I created a charting control for work in ASP.NET, and so far, they are thrilled. It has a bar chart, and a pie chart. Now they want a line chart (like a vertical bar). I have it working, but now they want each bar to look 3D. Each item is passed into a collection on the control. An item consists of a color and amount. The chart is built by the percentage of each item in the total of all items. Now they want the line chart (vertical bar) to have a 3D feel. I was able to get the 3D look, but I'm having a problem determining the values for the lighter and darker parts of each item. I need to figure out a lighter (and a darker) color for the passed value. For example, the bar color would be red. For the shadowed part of the bar, I need a darker red. For the top of the bar, I need a lighter color. But since each item color is being passed, I need to determine these colors on the fly. Something like GetDarkerColor(PassedColor) would be great. I just don't know how to determine these values. Any help would be greatly appreciated.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, you could convert to HSB (hue, saturation, brightness) using Color.GetXXX() methods, adjust brightness a bit, (watch out for over/underflow) and convert back. You need to write that part yourself ! This article[^] is my preferred article for june and may help you. BTW in the Java world GetLighter() and GetDarker() (or something of that nature) do exist. :)

      Luc Pattyn


      try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }


      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups