C#: Create a lighter/darker color based on a system color

前端 未结 11 1396
春和景丽
春和景丽 2020-12-07 18:26

Duplicate

How do I adjust the brightness of a color?
How do I determine darker or lighter color variant of a given color?
Programmat

11条回答
  •  离开以前
    2020-12-07 18:54

    You can also do this using a Lerp function. There's one in XNA, but it's easy to write yourself.

    See my answer to this similar question for a C# implementation.

    The function lets you do this:

    // make red 50% lighter:
    Color.Red.Lerp( Color.White, 0.5 );
    
    // make red 75% darker:
    Color.Red.Lerp( Color.Black, 0.75 );
    
    // make white 10% bluer:
    Color.White.Lerp( Color.Blue, 0.1 );
    

提交回复
热议问题