How can I generate multiple shades from a given base color?

前端 未结 3 1716
遥遥无期
遥遥无期 2020-12-28 08:49

I\'d like design a chart and set the colors from a single exemplar. Same way as in Excel\'s:

\"alt

相关标签:
3条回答
  • 2020-12-28 08:54

    That looks to me like they just took the same hue (basic color) and turned the brightness up and down. That can be done easily enough with a HSL or HSV transformations. Check Wikipedia for HSL and HSV color spaces to get some understanding of the theory involved.

    Basic idea: Computers represent color with a mixture of red intensity, green intensity and blue intensity, called RGB, because that's the way the screen displays color. HSL (Hue, Saturation, Lightness) and HSV (Hue, Saturation, Value) are two alternative models for representing color that are more intuitive and closer to the way human beings tend to think about how colors look.

    Hue is the basic color, represented (more or less) as an angle on a color wheel. Saturation is a linear value, from 0 (gray) to 255 (bright, vibrant color). And Lightness/Value represent brightness, from 0 (black) to 100 (white).

    The algorithms to transform from RGB -> HSL and HSL -> RGB (or HSV instead of HSL) are pretty straightforward. Try transforming your color to HS*, adjusting the brightness, and transforming back. By taking several different brightness values from low to high, and arranging them as wedges in a pie chart, you can duplicate that picture pretty easily.

    0 讨论(0)
  • 2020-12-28 08:54

    Roderick , the @mghie links are great to start, additionally try out the Colorlib Delphi Library , wich lets you convert between color models as well as HTML color conversion utilities. is very complete, full source code included and freeware ;).

    check the demo application , in this image you can see a blue pallete generated using this library.

    alt text

    0 讨论(0)
  • 2020-12-28 09:02

    Look into the HSV colour space. Using it you can produce different shades or tints starting from a given colour. There is a page with Pascal / Delphi code for conversion between RGB and HSV at efg's Computer Lab.

    0 讨论(0)
提交回复
热议问题