private void initColorsBlocks() { //ColorsOfMap.AddRange(new Color[]{ // Color.FromArgb(Alpha, 0, 0, 0) ,//Black // Color.FromArgb(Alpha, 0, 0, 0xFF) ,//Blue // Color.FromArgb(Alpha, 0, 0xFF, 0xFF) ,//Cyan // Color.FromArgb(Alpha, 0, 0xFF, 0) ,//Green // Color.FromArgb(Alpha, 0xFF, 0xFF, 0) ,//Yellow // Color.FromArgb(Alpha, 0xFF, 0, 0) ,//Red // Color.FromArgb(Alpha, 0xFF, 0xFF, 0xFF) // White //}); ColorsOfMap.AddRange(new Color[] { Color.FromArgb(Alpha, 0, 0, 0), //Black Color.FromArgb(Alpha, 0x94, 0, 0xD3), //violet Color.FromArgb(Alpha, 0x4B, 0, 0x82), //indigo Color.FromArgb(Alpha, 0, 0, 0xFF), //blue Color.FromArgb(Alpha, 0, 0xFF, 0), //green Color.FromArgb(Alpha, 0xFF, 0xFF, 0), //yellow Color.FromArgb(Alpha, 0xFF, 0x7F, 0), //orange Color.FromArgb(Alpha, 0xFF, 0, 0), Color.FromArgb(Alpha, 0, 0, 0) //Black }); //ColorsOfMap.AddRange(new Color[]{ // Color.FromArgb(Alpha, 0, 0, 0), // Black // Color.FromArgb(Alpha, 0xFF, 0, 0), //Red // Color.FromArgb(Alpha, 0xFF, 0xFF, 0xFF),// White //}); }
private void SeaTemperatureColors() { var array = new Color[] { Color.FromArgb(Alpha, 0, 0, 0), Color.FromArgb(Alpha, 0, 51, 255), Color.FromArgb(Alpha, 0, 204, 255), Color.FromArgb(Alpha, 0, 255, 255), Color.FromArgb(Alpha, 102, 255, 204), Color.FromArgb(Alpha, 0, 255, 51), Color.FromArgb(Alpha, 0, 204, 51), Color.FromArgb(Alpha, 153, 255, 102), Color.FromArgb(Alpha, 255, 255, 102), Color.FromArgb(Alpha, 255, 255, 0), Color.FromArgb(Alpha, 255, 153, 0), Color.FromArgb(Alpha, 255, 102, 0), Color.FromArgb(Alpha, 255, 51, 0), Color.FromArgb(Alpha, 204, 0, 0), Color.FromArgb(Alpha, 153, 0, 0), Color.FromArgb(Alpha, 153, 0, 153), Color.FromArgb(Alpha, 255, 0, 255) }; ColorsOfMap.AddRange(array); }
private void InitColorsBlocks() { ColorsOfMap.AddRange(new[] { new Color(0, 0, 0xFF), //Blue new Color(0, 0xFF, 0xFF), //Cyan new Color(0, 0xFF, 0), //Green new Color(0xFF, 0xFF, 0), //Yellow new Color(0xFF, 0, 0), //Red }); }
private void initColorsBlocks() { ColorsOfMap.AddRange(new Color[] { Color.FromArgb(Alpha, 0, 0, 0), //Black Color.FromArgb(Alpha, 0, 0, 0xFF), //Blue Color.FromArgb(Alpha, 0, 0xFF, 0xFF), //Cyan Color.FromArgb(Alpha, 0, 0xFF, 0), //Green Color.FromArgb(Alpha, 0xFF, 0xFF, 0), //Yellow Color.FromArgb(Alpha, 0xFF, 0, 0), //Red Color.FromArgb(Alpha, 0xFF, 0xFF, 0xFF) // White }); }
public Color GetColorForValue(double val, double maxVal) { double valPercent = val / maxVal; // value% if (valPercent >= 1) { return(ColorsOfMap.Last()); } double colorPercent = 1d / (ColorsOfMap.Count - 1); // % of each block of color. the last is the "100% Color" double blockOfColor = valPercent / colorPercent; // the integer part repersents how many block to skip int blockIdx = (int)Math.Truncate(blockOfColor); // Idx of double valPercentResidual = valPercent - (blockIdx * colorPercent); //remove the part represented of block double percentOfColor = valPercentResidual / colorPercent; // % of color of this block that will be filled Color cTarget = ColorsOfMap[blockIdx]; Color cNext = ColorsOfMap[blockIdx + 1]; var deltaR = cNext.R - cTarget.R; var deltaG = cNext.G - cTarget.G; var deltaB = cNext.B - cTarget.B; var r = cTarget.R + deltaR * percentOfColor; var g = cTarget.G + deltaG * percentOfColor; var b = cTarget.B + deltaB * percentOfColor; Color c = ColorsOfMap[0]; try { c = new Color((byte)r, (byte)g, (byte)b); } catch (Exception) { // ignored } return(c); }
private void InitColorsBlocks() { // ColorsOfMap.AddRange(new Color[]{ // Color.FromArgb(Alpha, 0, 0, 0) ,//Black // Color.FromArgb(Alpha, 0, 0, 0xFF) ,//Blue // Color.FromArgb(Alpha, 0, 0xFF, 0xFF) ,//Cyan // Color.FromArgb(Alpha, 0, 0xFF, 0) ,//Green // Color.FromArgb(Alpha, 0xFF, 0xFF, 0) ,//Yellow // Color.FromArgb(Alpha, 0xFF, 0, 0) ,//Red // Color.FromArgb(Alpha, 0xFF, 0xFF, 0xFF) // White //}); for (var i = 0; i < 255; i += 25) { Color color = Color.FromArgb(Alpha, i, i, i); ColorsOfMap.Add(color); } //for (var i = 255; i >= 0; i -= 25) //{ // Color color = Color.FromArgb(Alpha, i, i, i); // ColorsOfMap.Add(color); //} }