private void RefreshPalette(double hue) { hue = Math.Round(hue, 2); if (hue == oldHue) { return; } oldHue = hue; if (!palette.ContainsKey(hue)) { var b = new SimpleBitmap(255, 255); var colors = new Color[255, 255]; for (int x = 0; x < 255; x++) { for (int y = 0; y < 255; y++) { Color color = RGBHSL.HSL_to_RGB(new RGBHSL.HSL(hue, x / 255.0, y / 255.0, 1)); colors[x, y] = color; } } b.SetPixelsFromArray(colors); palette[hue] = b; } image.Source = palette[hue].BaseBitmap; }
private void HiLiteRow(GridViewRow row) { if (DoHiLiteRow) { // Change cursor to hand row.Style["cursor"] = "pointer"; // The 50% color of the background Color BackColorLight = Color.Empty; Color BackColor = Color.Empty; // Get the back color BackColor = ((row.RowState == DataControlRowState.Alternate) ? AlternatingRowStyle.BackColor : RowStyle.BackColor); // Generate a light version BackColorLight = RGBHSL.ModifyBrightness(BackColor, .8); // Add the mouse over and mouse out javascript events here row.Attributes.Add("onmouseover", "javascript:this.style.backgroundColor = '" + ColorTranslator.ToHtml(BackColorLight) + "';"); row.Attributes.Add("onmouseout", "javascript:this.style.backgroundColor = '" + ColorTranslator.ToHtml(BackColor) + "';"); //set up the post back for a row when it is clicked row.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(this, "Select$" + row.RowIndex.ToString())); } }
public Color BrightenColor(EliteAPI.ChatEntry chatLine) { Color brighterColor = new Color(); //how many steps away can the colors be away from each other to be close enough to grayscale //this variable's value is subjective, and chosen by the programmer int steps = 3; //tolerance = 256 colors / 64 in-game 'step' choices * steps int tolerance = 256 / 64 * steps; int closeEnoughRG = Math.Abs(chatLine.ChatColor.R - chatLine.ChatColor.G); int closeEnoughGB = Math.Abs(chatLine.ChatColor.G - chatLine.ChatColor.B); int closeEnoughRB = Math.Abs(chatLine.ChatColor.R - chatLine.ChatColor.B); if ((closeEnoughRG <= tolerance) && (closeEnoughGB <= tolerance) && (closeEnoughRB <= tolerance)) { //greatly brighten white and gray text brighterColor = RGBHSL.ModifyBrightness(chatLine.ChatColor, 1.85); } else { //only slighty brighten color text brighterColor = RGBHSL.ModifyBrightness(chatLine.ChatColor, 1.25); } return(brighterColor); }