Programmatically choose high-contrast colors

前端 未结 10 692
野的像风
野的像风 2020-12-14 07:29

This should be a simple question, but I haven\'t been able to find a way to make it work.

Essentially, I have a silly localhost page that I use in my webdevelopment.

10条回答
  •  [愿得一人]
    2020-12-14 07:36

    private Color GetContrastingColor(Color color)
    {
        int r = color.R > 0 ? 256 - color.R : 255;
        int g = color.G > 0 ? 256 - color.G : 255;
        int b = color.B > 0 ? 256 - color.B : 255;
        return System.Drawing.Color.FromArgb(r, g, b);
    }
    

提交回复
热议问题