在之前的一篇文章<将16进制的颜色转为rgb颜色>中,曾经写过将16进制的颜色转换为rgb颜色. 当然了,今天再看,还是有很多可以优化的地方,所以对之前的代码重构了一遍,并且同时写了一个反向转换(也就是将rgb颜色值转换为字符串形式的16进制的颜色值)函数. 16进制转换rgb: function transferColorToRgb(color) { if (typeof color !== 'string' && !(color instanceof String)) re
(1)方式一: Color color1 = (Color)System.Windows.Media.ColorConverter.ConvertFromString("#E0E0E0"); (2)方式二: Color color2 = ConvertToColor("#E0E0E0"); public static System.Windows.Media.Color ConvertToColor(string value) { int r = 0, g = 0,
Introduction Why an article on "colors"? It's the same question I asked myself before writing this series. The fact is, in .NET, there are only two color formats that can be used: the RGB color model and the HSB color model. Those two are encaps
RGB to HSL The R,G,B values are divided by 255 to change the range from 0..255 to 0..1: R' = R/255 G' = G/255 B' = B/255 Cmax = max(R', G', B') Cmin = min(R', G', B') Δ = Cmax - Cmin Hue calculation: Saturation calculation: Lightness calculation: L =