/// <summary> /// Initializes a new instance of the <see cref="Custom" /> struct with /// a default color for each LED. /// </summary> /// <param name="color">The color to set each LED to initially.</param> public Custom(Color color) { Colors = new Color[Constants.MaxLeds]; for (var i = 0; i < Colors.Length; i++) Colors[i] = color; }
/// <summary> /// Initializes a new instance of the <see cref="Breathing" /> struct. /// </summary> /// <param name="led">The LED on which to apply the effect.</param> /// <param name="type">The type of breathing effect to create.</param> /// <param name="first">The initial <see cref="Color" /> to use.</param> /// <param name="second">The second color.</param> public Breathing(Led led, BreathingType type, Color first, Color second) { Led = led; Type = type; First = first; Second = second; }
public static void SetColorsToTextColor(ColoreColor color) { if (OLDTVResources.currentGameMode == null) { color = ColoreColor.Black; } if (Plugin.chromaMode == "colorful") { Chroma.Instance.SetAll(color); } if (Plugin.chromaMode == "default") { Chroma.Instance.Keyboard[Key.F1] = color; Chroma.Instance.Keyboard[Key.F2] = color; Chroma.Instance.Keyboard[Key.F3] = color; Chroma.Instance.Keyboard[Key.F4] = color; Chroma.Instance.Keyboard[Key.F5] = color; Chroma.Instance.Keyboard[Key.F6] = color; Chroma.Instance.Keyboard[Key.F7] = color; Chroma.Instance.Keyboard[Key.F8] = color; Chroma.Instance.Keyboard[Key.F9] = color; Chroma.Instance.Keyboard[Key.F10] = color; Chroma.Instance.Keyboard[Key.F11] = color; Chroma.Instance.Keyboard[Key.F12] = color; Chroma.Instance.Mouse.SetLed(Corale.Colore.Razer.Mouse.Led.ScrollWheel, color); Chroma.Instance.Mouse.SetLed(Corale.Colore.Razer.Mouse.Led.Backlight, color); Chroma.Instance.Mouse.SetLed(Corale.Colore.Razer.Mouse.Led.Logo, color); Chroma.Instance.Mousepad.SetAll(color); Chroma.Instance.Keypad.SetAll(color); ChromaLink.Instance.SetAll(color); } }
/// <summary> /// Initializes a new instance of the <see cref="Reactive" /> struct. /// </summary> /// <param name="duration">Effect duration.</param> /// <param name="color">Effect color.</param> /// <param name="parameter">Additional effect parameter.</param> public Reactive(Duration duration, Color color, int parameter = 0) { Duration = duration; Color = color; Parameter = parameter; Size = Marshal.SizeOf(typeof(Reactive)); }
/// <summary> /// Paints heat displays onto all connected devices except keyboards and keypads. /// </summary> /// <param name="colorScheme"></param> private void DisplayHeat(ColorScheme colorScheme) { var heat = 0.0; if (colorScheme.OtherValues.ContainsKey("Heat")) { heat = colorScheme.OtherValues["Heat"]; } float red, green, blue; if (heat >= 0.5) { heat = 2 * heat - 1.0; red = warm.R + (hot.R - warm.R) * (float)heat; green = warm.G + (hot.G - warm.G) * (float)heat; blue = warm.B + (hot.B - warm.B) * (float)heat; } else { heat = 2 * heat; red = cold.R + (warm.R - cold.R) * (float)heat; green = cold.G + (warm.G - cold.G) * (float)heat; blue = cold.B + (warm.B - cold.B) * (float)heat; } // Display heat on all LEDs we have var heatColor = new Color(red, green, blue); this.mouseGrid.Set(heatColor); this.mousePadGrid.Set(heatColor); }
static void PrintJDH(ColoreColor color) { MakeJ(color); MakeD(color); MakeH(color); Chroma.Instance.Keyboard.SetCustom(keyboardGrid); }
private void ynhSetKeys_DoWork(object sender, DoWorkEventArgs e) { ColoreCore.Chroma.Instance.Keyboard.SetAll(ColoreCore.Color.Black); Utils utils = new Utils(); List <int> success = new List <int>(); foreach (DataGridViewRow row in ynhDataGridView.Rows) { if (row.Cells[0].Value == null) { continue; } var color_rgb_array = row.Cells[1].Value.ToString().ToCharArray(); string color_raw = row.Cells[1].Value.ToString(); if (color_rgb_array[0].Equals('#')) { color_raw = utils.HexToRgb(color_raw); } else if (char.IsLetter(color_rgb_array[0])) { color_raw = utils.NameToRgb(color_raw); } else { color_raw = row.Cells[1].Value.ToString(); } if (color_raw.Split(',').Length != 3) { //logger.Error("Colore male configurato! '{0}'", temp.Color); continue; } var color_rbg = Array.ConvertAll(color_raw.Replace(" ", "").Split(','), byte.Parse); var letters = row.Cells[0].Value.ToString().ToCharArray(); ColoreCore.Color color = new ColoreCore.Color(color_rbg[0], color_rbg[1], color_rbg[2]); DataGridViewCheckBoxCell numpad = (DataGridViewCheckBoxCell)row.Cells[2]; for (int i = 0; i < letters.Length; i++) { string myChar = char.ToString(char.ToUpper(letters[i])); if (char.IsNumber(letters[i])) { if ((bool)numpad.Value) { myChar = "Num" + myChar; } else { myChar = "D" + myChar; } } //logger.Debug("Carattere: {0}", (string)myChar); ColoreCore.Chroma.Instance.Keyboard.SetKey(utils.GetKey(myChar), color); Thread.Sleep(10); } success.Add(row.Index); //ynhDataGridView.Refresh(); } e.Result = success; }
private void UpdateDevices(dynamic msg) { if (msg.characteristic == "Hue") { UpdateLabel(HueFeed, Convert.ToString(msg)); } if (msg.characteristic == "Saturation") { UpdateLabel(SaturationFeed, Convert.ToString(msg)); } Console.Write(msg.characteristic); Console.WriteLine(msg.value); if (msg.characteristic == "On" && msg.value == "False") { fV = 0; } else if (msg.characteristic == "On" && msg.value == "True") { fV = prev; } if (msg.characteristic == "Hue") { fH = msg.value; } if (msg.characteristic == "Saturation") { fS = msg.value; } if (msg.characteristic == "Brightness") { fV = msg.value; } HSV data = new HSV(fH, fS / 100, fV / 100); RGB value = HSVToRGB(data); UpdateLabel(label2, Convert.ToString(value.R)); UpdateLabel(label3, Convert.ToString(value.G)); UpdateLabel(label4, Convert.ToString(value.B)); var color = new ColoreColor((byte)value.R, (byte)value.G, (byte)value.B); Chroma.Instance.SetAll(color); if (fV != 0) { prev = fV; } }
private static void SetAllOnMousepad(ColoreColor color) { for (int g = 0; g < Corale.Colore.Razer.Mousepad.Constants.MaxLeds; g++) { _customMousepad[g] = color; } Chroma.Instance.Mousepad.SetCustom(_customMousepad); }
/// <summary> /// Initializes a new instance of the <see cref="Breathing" /> struct. /// </summary> /// <param name="type">The type of breathing effect to create.</param> /// <param name="first">Primary effect color.</param> /// <param name="second">Secondary effect color.</param> /// <param name="parameter">Additional effect parameter to set.</param> public Breathing(BreathingType type, Color first, Color second, int parameter = 0) { Type = type; First = first; Second = second; Parameter = parameter; Size = Marshal.SizeOf(typeof(Breathing)); }
public static void UpdateMouseColors(int primred, int primgreen, int primblue) { Color.Default.MousePrimaryRed = primred; Color.Default.MousePrimaryGreen = primgreen; Color.Default.MousePrimaryBlue = primblue; Color.Default.Save(); _mousePrimaryColor = new ColoreColor((byte)Color.Default.MousePrimaryRed, (byte)Color.Default.MousePrimaryGreen, (byte)Color.Default.MousePrimaryBlue); }
private static void SetAllOnMouse(ColoreColor color) { for (int i = 0; i < Corale.Colore.Razer.Mouse.Constants.MaxLeds; i++) { _customMouse[i] = color; } Chroma.Instance.Mouse.SetCustom(_customMouse); }
/// <summary> /// Set all the LEDs as the same color /// </summary> /// <param name="color"></param> void SetColor(Corale.Colore.Core.Color color) { for (int i = 0; i < Corale.Colore.Razer.Mousepad.Constants.MaxLeds; ++i) { _mCustomEffect[i] = color; } Corale.Colore.Core.Mousepad.Instance.SetCustom(_mCustomEffect); }
public AnimatedKey(Key key, Color color) { this.razerKey = key; this.color = color; this.red = color.R; this.green = color.G; this.blue = color.B; this.alpha = color.A; }
public void ShouldConstructFromSystemColor() { var source = System.Drawing.Color.FromArgb(5, 10, 15); var coloreColor = new Color(source); Assert.AreEqual(source.R, coloreColor.R); Assert.AreEqual(source.G, coloreColor.G); Assert.AreEqual(source.B, coloreColor.B); }
/// <summary> /// From a given resized screenshot, an ambilight effect will be created for the mousepad ///^->>i ///^ V ///^ V ///<<<<V /// /// </summary> /// <param name="mapMousePad">resized screenshot</param> /// <param name="mousePadGrid">effect grid</param> /// <returns></returns> private Custom GenerateMousePadGrid(Bitmap mapMousePad, Custom mousePadGrid) { if (!settings.AmbiModeBool) { for (int i = 0; i < 4; i++) { Color color = mapMousePad.GetPixel(6, i); mousePadGrid[i] = new ColoreColor((byte)color.R, (byte)color.G, (byte)color.B); } Color colorC = mapMousePad.GetPixel(6, 4); mousePadGrid[4] = new ColoreColor((byte)colorC.R, (byte)colorC.G, (byte)colorC.B); for (int i = 5; i >= 0; i--) { Color color = mapMousePad.GetPixel(i, 5); mousePadGrid[10 - i] = new ColoreColor((byte)color.R, (byte)color.G, (byte)color.B); } for (int i = 3; i >= 0; i--) { Color color = mapMousePad.GetPixel(0, i); mousePadGrid[14 - i] = new ColoreColor((byte)color.R, (byte)color.G, (byte)color.B); } } else { //RIGHT for (int i = 0; i < 4; i++) { Color color = mapMousePad.GetPixel(6, 5); mousePadGrid[i] = new ColoreColor((byte)color.R, (byte)color.G, (byte)color.B); } //RIGHT DOWN CORNOR Color colorC = mapMousePad.GetPixel(6, 5); mousePadGrid[4] = new ColoreColor((byte)colorC.R, (byte)colorC.G, (byte)colorC.B); //BOTTOM for (int i = 5; i >= 0; i--) { Color color = mapMousePad.GetPixel(5, 5); mousePadGrid[10 - i] = new ColoreColor((byte)color.R, (byte)color.G, (byte)color.B); } ///CORNER + LEFT for (int i = 3; i >= 0; i--) { Color color = mapMousePad.GetPixel(4, 5); mousePadGrid[14 - i] = new ColoreColor((byte)color.R, (byte)color.G, (byte)color.B); } } return(mousePadGrid); }
// Create a custom for the Keyboard // Set the D to color static void MakeD(ColoreColor color) { int i = 0; while (i < KeyD.Length) { keyboardGrid[KeyD[i]] = color; i++; } }
public void ShouldConstructFromRgb() { var expected = new Color(0x123456); var actual = Color.FromRgb(0x563412); Assert.AreEqual(expected.Value, actual.Value); Assert.AreEqual(expected.R, actual.R); Assert.AreEqual(expected.G, actual.G); Assert.AreEqual(expected.B, actual.B); }
// Create a custom for the Keyboard // Set the A Key to color static void MakeJ(ColoreColor color) { int i = 0; while (i < KeyJ.Length) { keyboardGrid[KeyJ[i]] = color; i++; } keyboardGrid[4, 2] = color; }
/// <summary> /// Applies the color scheme to the keyboard. /// </summary> /// <param name="colorScheme">The color scheme to apply.</param> private static void ApplyToKeyboard(ColorScheme colorScheme) { if (colorScheme != null) { foreach (var key in keyMapping) { var keyColor = new Color(colorScheme[key.Key].r, colorScheme[key.Key].g, colorScheme[key.Key].b); Keyboard.Instance.SetKey(key.Value, keyColor); } } }
public void ShouldConvertRgbBytesCorrectly() { const uint V = 0x00FFFFFF; const byte R = 255; const byte G = 255; const byte B = 255; var c = new Color(R, G, B); Assert.AreEqual(c.Value, V); Assert.AreEqual(c.R, R); Assert.AreEqual(c.G, G); Assert.AreEqual(c.B, B); }
private static void SetAllOnKeyboard(ColoreColor color) { for (int r = 0; r < Corale.Colore.Razer.Keyboard.Constants.MaxRows; r++) { for (int c = 0; c < Corale.Colore.Razer.Keyboard.Constants.MaxColumns; c++) { _customKeyboard[r, c] = color; } } Chroma.Instance.Keyboard.SetCustom(_customKeyboard); }
private void BacklightOn() { uint chromaValue = (uint)((razerBacklightValues[currentBacklightPercentIndex] << 16) | (razerBacklightValues[currentBacklightPercentIndex] << 8) | (razerBacklightValues[currentBacklightPercentIndex])); int logiValue = logiBacklightValues[currentBacklightPercentIndex]; #if !UI_DESIGN Chroma.Instance.Mouse.SetAll(ColoreColor.FromRgb(chromaValue)); LogitechGSDK.LogiLedSetLighting(logiValue, logiValue, logiValue); DoNumlockIndicator(); #endif }
public void ShouldConvertRgbDoublesCorrectly() { const uint V = 0x00FFFFFF; const double R = 1.0; const double G = 1.0; const double B = 1.0; const byte Expected = 255; var c = new Color(R, G, B); Assert.AreEqual(c.Value, V); Assert.AreEqual(c.R, Expected); Assert.AreEqual(c.G, Expected); Assert.AreEqual(c.B, Expected); }
private Color getNewColor(Color color) { var magicNumber = 255; var darkenedColor = darkenColor((int)red, (int)green, (int)blue); red = darkenedColor[0]; green = darkenedColor[1]; blue = darkenedColor[2]; //temporarily not touching alpha, as it doesn't work at all. //Yet. alpha = color.A; return new Color(red / magicNumber, green / magicNumber, blue / magicNumber, alpha); }
private void DisplayHeadset(ColorScheme scheme) { var saveStateColor = new Color(scheme[KeyCode.F5].r, scheme[KeyCode.F5].g, scheme[KeyCode.F5].b); if (saveStateColor.R == 1f && saveStateColor.G == 0f && saveStateColor.B == 0f) { this.headSetGrid = new Static(Color.Red); } else { this.headSetGrid = new Static(Color.Green); } }
/* * a = 2,2 * z = 2,3 * e = 2,4 * s = 3,3 * < = 4,2 * w = 4,3 * * * * t= 2,6 * y = 2,7 * u = 2,8 * g = 3,6 * j = 3,8 * v = 4,6 * B = 4,7 * N = 4,8 * * * o = 2,10 * ^ = 2,12 * l = 3,10 * m = 3,11 * ù = 3,12 * ; = 4,10 * ! = 4,12 * */ static void fillList(ColoreColor color) { PosInfo posInfo; posInfo = new PosInfo(2, 2, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(2, 3, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(2, 4, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(3, 3, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(4, 2, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(4, 3, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(2, 6, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(2, 7, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(2, 8, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(3, 6, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(3, 8, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(4, 6, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(4, 7, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(4, 8, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(2, 10, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(2, 12, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(3, 10, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(3, 11, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(3, 12, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(4, 10, color); listPosInfo.Add(posInfo); posInfo = new PosInfo(4, 12, color); listPosInfo.Add(posInfo); }
public void ShouldConvertRgbBytesCorrectly() { const uint V = 0x8056F5C8; const byte R = 200; const byte G = 245; const byte B = 86; const byte A = 128; var c = new Color(R, G, B, A); Assert.AreEqual(c.Value, V); Assert.AreEqual(c.R, R); Assert.AreEqual(c.G, G); Assert.AreEqual(c.B, B); Assert.AreEqual(c.A, A); }
static void SetColor(int r, int g, int b) { //Initialise the SDK if it has not yet been initialised. if (!initialised) { Initialise(); } //Create a color based on the rgb values. var color = new ColoreColor((byte)r, (byte)g, (byte)b); //Set all connected Razer Chroma devices to the given color. Chroma.Instance.SetAll(color); }
/// <summary> /// Highlight mouse position /// </summary> /// <param name="color"></param> void HighlightMousePosition(Corale.Colore.Core.Color color) { for (int i = 1; i < Corale.Colore.Razer.Mousepad.Constants.MaxLeds; ++i) { if (i >= (GetIndex() - 1) && i <= (GetIndex() + 1)) { _mCustomEffect[i] = color; } else { _mCustomEffect[i] = Corale.Colore.Core.Color.Black; } } Corale.Colore.Core.Mousepad.Instance.SetCustom(_mCustomEffect); }
private static void HighlightMousePosition(ColoreColor color) { for (var i = 0; i < Corale.Colore.Razer.Mousepad.Constants.MaxLeds; ++i) { if (i >= (GetIndex() - 1) && i <= (GetIndex() + 1)) { _customMousepad[i] = color; } else { _customMousepad[i] = _mousePrimaryColor; } } Chroma.Instance.Mousepad.SetCustom(_customMousepad); }
// Create a custom for the Keyboard // Set the H Key to color static void MakeH(ColoreColor color) { int i = 0; while (i < KeyH.Length) { keyboardGrid[KeyH[i]] = color; i++; } keyboardGrid[2, 12] = color; keyboardGrid[3, 12] = color; keyboardGrid[3, 11] = color; keyboardGrid[4, 10] = color; keyboardGrid[4, 12] = color; }
public void ShouldConvertRgbDoublesCorrectly() { const uint V = 0x7F3D89CC; const double R = 0.8; const double G = 0.54; const double B = 0.24; const double A = 0.5; const byte ExpectedR = (byte)(R * 255); const byte ExpectedG = (byte)(G * 255); const byte ExpectedB = (byte)(B * 255); const byte ExpectedA = (byte)(A * 255); var c = new Color(R, G, B, A); Assert.AreEqual(c.Value, V); Assert.AreEqual(c.R, ExpectedR); Assert.AreEqual(c.G, ExpectedG); Assert.AreEqual(c.B, ExpectedB); Assert.AreEqual(c.A, ExpectedA); }
void Update() { // When left mouse is pressed if (Input.GetMouseButton(0)) { // set the logo _mCustomEffect[0] = _mTargetColor; // highlight mouse position HighlightMousePosition(_mTargetColor); // set camera to target color Camera.main.backgroundColor = Color.green; // do a slow fade when mouse is unpressed _mTimer = DateTime.Now + TimeSpan.FromMilliseconds(500); } // fade to black when not pressed else if (_mTimer > DateTime.Now) { float t = (float)(_mTimer - DateTime.Now).TotalSeconds / 0.5f; Corale.Colore.Core.Color color = new Corale.Colore.Core.Color(0, (double)t, 0); SetColor(color); Camera.main.backgroundColor = Color.Lerp(Color.green, Color.black, 1f-t); } // times up else if (_mTimer != DateTime.MinValue) { // clear the color Corale.Colore.Core.Mousepad.Instance.Clear(); // set camera black Camera.main.backgroundColor = Color.black; // unset the timer _mTimer = DateTime.MinValue; } // highlight the mouse position when button is not pressed else { // highlight mouse position HighlightMousePosition(Corale.Colore.Core.Color.Blue); } }
public void DrawHeat(int healthperc, bool CompleteColor) { ColorBlender cb = new ColorBlender(System.Drawing.Color.Red, System.Drawing.Color.Green); cb.bluecomplete = CompleteColor; cb.CompleteColor = System.Drawing.Color.Aqua; Color c = cb.GetColor2(healthperc); try { for (int i = 1; i < 22; i++) { for (int r = 2; r < 5; r++) { Chroma.Instance.Keyboard[r, i] = c; } } } catch (Exception) { } }
public void DrawHealth(int healthperc, bool CompleteColor) { ColorBlender cb = new ColorBlender(System.Drawing.Color.Red, System.Drawing.Color.Green); cb.bluecomplete = CompleteColor; cb.CompleteColor = System.Drawing.Color.Aqua; Color c = cb.GetColor2(healthperc); try { for (int i = 1; i < (int)(18 * healthperc / 100); i++) { Chroma.Instance.Keyboard[0, i] = c; } for (int i = (int)(18 * healthperc / 100); i < 18; i++) { Chroma.Instance.Keyboard[0, i] = Color.Black; } } catch (Exception) { } }
public void randoKeyTimer(Object source, EventArgs e) { Random rnd = new Random(); for (int r = 0; r < Constants.MaxRows; r++) { for (int c = 0; c < Constants.MaxColumns; c++) { if (rnd.Next(0, 1) == 0) { keyboardGrid[r, c] = ColoreColor.Black; } else { byte curRColor = (byte)(rnd.Next(255)); byte curGColor = (byte)(rnd.Next(255)); byte curBColor = (byte)(rnd.Next(255)); keyboardGrid[r, c] = new ColoreColor((byte)(curRColor), (byte)(curGColor), (byte)(curBColor)); } } } }
/// <summary> /// From a given resized screenshot, an ambilight effect will be created for the keyboard /// </summary> /// <param name="map">resized screenshot</param> /// <param name="keyboardGrid">effect grid</param> /// <returns>EffectGrid</returns> private KeyboardCustom GenerateKeyboardGrid(Bitmap map, KeyboardCustom keyboardGrid) { //Iterating over each key and set it to the corrosponding color of the resized Screenshot for (var r = 0; r < settings.KeyboardHeight; r++) { for (var c = 0; c < settings.KeyboardWidth; c++) { System.Drawing.Color color; if (settings.AmbiModeBool) { color = map.GetPixel(c, settings.KeyboardHeight - 1); } else { color = map.GetPixel(c, r); } keyboardGrid[r, c] = new ColoreColor((byte)color.R, (byte)color.G, (byte)color.B); } } return(keyboardGrid); }
private void DisplayElectricity(ColorScheme colorScheme) { var electricity = 0.0; if (colorScheme.OtherValues.ContainsKey("ElectricCharge")) { electricity = colorScheme.OtherValues["ElectricCharge"]; } // Color the outside led rows with an electricity gauge, overwriting heat displays on a mouse var mouseElectricity = electricity * (Constants.MaxRows - 2); for (var i = 1; i < Constants.MaxRows - 1; i++) { var colorStrength = (float)Math.Min(mouseElectricity - (i - 1), 1.0); // Cyan has a standard code of 0,1,1; so passing in the raw strength has the same effect. var padLedColor = new Color(0.0, colorStrength, colorStrength); this.mouseGrid[Constants.MaxRows - 1 - i, 0] = padLedColor; this.mouseGrid[Constants.MaxRows - 1 - i, Constants.MaxColumns - 1] = padLedColor; } // Color the outside led rows with an electricity gauge, overwriting heat displays on a mousepad var padElectricity = electricity * 5.0; for (var i = 0; i < 5; i++) { var colorStrength = (float)Math.Min(padElectricity - i, 1.0); // Cyan has a standard code of 0,1,1; so passing in the raw strength has the same effect. var gripLedColor = new Color(0.0, colorStrength, colorStrength); this.mousePadGrid[4 - i] = gripLedColor; this.mousePadGrid[10 + i] = gripLedColor; } }
/// <summary> /// From a given resized screenshot, an ambilight effect will be created for the mouse /// </summary> /// <param name="mapMousePad">resized screenshot</param> /// <param name="mousePadGrid">effect grid</param> /// <returns>EffectGrid</returns> private CustomGrid GenerateMouseGrid(Bitmap mapMouse, CustomGrid mouseGrid) { for (var r = 0; r < Corale.Colore.Razer.Mouse.Constants.MaxRows; r++) { for (var c = 0; c < Corale.Colore.Razer.Mouse.Constants.MaxColumns; c++) { System.Drawing.Color color; if (settings.AmbiModeBool) { color = mapMouse.GetPixel(6, 8); } else { color = mapMouse.GetPixel(c, r); } mouseGrid[r, c] = new ColoreColor((byte)color.R, (byte)color.G, (byte)color.B); } } return(mouseGrid); }
private static void MouseAndMousepadReactive() { //events when MouseButton pressed if (MainForm.IsMouseButtonPressed) { SetAllOnMouse(_mouseTertiaryColor); _flMouseAnimationRed = Color.Default.MouseTertiaryRed; _flMouseAnimationGreen = Color.Default.MouseTertiaryGreen; _flMouseAnimationBlue = Color.Default.MouseTertiaryBlue; HighlightMousePosition(_mouseTertiaryColor); _objTimer = DateTime.Now + TimeSpan.FromMilliseconds(1000); _isAnimationReady = false; } //events when MouseButton released else if (_objTimer > DateTime.Now) { var color = new ColoreColor((byte)_flMouseAnimationRed, (byte)_flMouseAnimationGreen, (byte)_flMouseAnimationBlue); SetAllOnMousepad(color); SetAllOnMouse(color); if (Color.Default.MousePrimaryRed > Color.Default.MouseTertiaryRed) { _flMouseAnimationRed = _flMouseAnimationRed + ((float)(Color.Default.MousePrimaryRed - Color.Default.MouseTertiaryRed) / 400); if (_flMouseAnimationRed >= Color.Default.MousePrimaryRed) { _flMouseAnimationRed = Color.Default.MousePrimaryRed; } } else if (Color.Default.MousePrimaryRed < Color.Default.MouseTertiaryRed) { _flMouseAnimationRed = _flMouseAnimationRed - ((float)(Color.Default.MouseTertiaryRed - Color.Default.MousePrimaryRed) / 400); if (_flMouseAnimationRed <= Color.Default.MousePrimaryRed) { _flMouseAnimationRed = Color.Default.MousePrimaryRed; } } if (Color.Default.MousePrimaryGreen > Color.Default.MouseTertiaryGreen) { _flMouseAnimationGreen = _flMouseAnimationGreen + ((float)(Color.Default.MousePrimaryGreen - Color.Default.MouseTertiaryGreen) / 400); if (_flMouseAnimationGreen >= Color.Default.MousePrimaryGreen) { _flMouseAnimationGreen = Color.Default.MousePrimaryGreen; } } else if (Color.Default.MousePrimaryGreen < Color.Default.MouseTertiaryGreen) { _flMouseAnimationGreen = _flMouseAnimationGreen - ((float)(Color.Default.MouseTertiaryGreen - Color.Default.MousePrimaryGreen) / 400); if (_flMouseAnimationGreen <= Color.Default.MousePrimaryGreen) { _flMouseAnimationGreen = Color.Default.MousePrimaryGreen; } } if (Color.Default.MousePrimaryBlue > Color.Default.MouseTertiaryBlue) { _flMouseAnimationBlue = _flMouseAnimationBlue + ((float)(Color.Default.MousePrimaryBlue - Color.Default.MouseTertiaryBlue) / 400); if (_flMouseAnimationBlue >= Color.Default.MousePrimaryBlue) { _flMouseAnimationBlue = Color.Default.MousePrimaryBlue; } } else if (Color.Default.MousePrimaryBlue < Color.Default.MouseTertiaryBlue) { _flMouseAnimationBlue = _flMouseAnimationBlue - ((float)(Color.Default.MouseTertiaryBlue - Color.Default.MousePrimaryBlue) / 400); if (_flMouseAnimationBlue <= Color.Default.MousePrimaryBlue) { _flMouseAnimationBlue = Color.Default.MousePrimaryBlue; } } } //setting values after mousebutton release animations are done else if (_objTimer != DateTime.MinValue) { _flMouseAnimationRed = Color.Default.MousePrimaryRed; _flMouseAnimationGreen = Color.Default.MousePrimaryGreen; _flMouseAnimationBlue = Color.Default.MousePrimaryBlue; _objTimer = DateTime.MinValue; _objTimer2 = DateTime.Now + TimeSpan.FromMilliseconds(1000); } //return to default mode on mouse and mousepad else { //return to primary color on the mouse SetAllOnMouse(_mousePrimaryColor); //Fade back in "highlight Mouseposition" if (_objTimer2 > DateTime.Now) { HighlightMousePosition(new ColoreColor((byte)_flMouseAnimationRed, (byte)_flMouseAnimationGreen, (byte)_flMouseAnimationBlue)); if (Color.Default.MouseSecondaryRed > Color.Default.MousePrimaryRed) { _flMouseAnimationRed = _flMouseAnimationRed + ((float)(Color.Default.MouseSecondaryRed - Color.Default.MousePrimaryRed) / 238); if (_flMouseAnimationRed >= Color.Default.MouseSecondaryRed) { _flMouseAnimationRed = Color.Default.MouseSecondaryRed; } } else if (Color.Default.MouseSecondaryRed < Color.Default.MousePrimaryRed) { _flMouseAnimationRed = _flMouseAnimationRed - ((float)(Color.Default.MousePrimaryRed - Color.Default.MouseSecondaryRed) / 238); if (_flMouseAnimationRed <= Color.Default.MouseSecondaryRed) { _flMouseAnimationRed = Color.Default.MouseSecondaryRed; } } if (Color.Default.MouseSecondaryGreen > Color.Default.MousePrimaryGreen) { _flMouseAnimationGreen = _flMouseAnimationGreen + ((float)(Color.Default.MouseSecondaryGreen - Color.Default.MousePrimaryGreen) / 238); if (_flMouseAnimationGreen >= Color.Default.MouseSecondaryGreen) { _flMouseAnimationGreen = Color.Default.MouseSecondaryGreen; } } else if (Color.Default.MouseSecondaryGreen < Color.Default.MousePrimaryGreen) { _flMouseAnimationGreen = _flMouseAnimationGreen - ((float)(Color.Default.MousePrimaryGreen - Color.Default.MouseSecondaryGreen) / 238); if (_flMouseAnimationGreen <= Color.Default.MouseSecondaryGreen) { _flMouseAnimationGreen = Color.Default.MouseSecondaryGreen; } } if (Color.Default.MouseSecondaryBlue > Color.Default.MousePrimaryBlue) { _flMouseAnimationBlue = _flMouseAnimationBlue + ((float)(Color.Default.MouseSecondaryBlue - Color.Default.MousePrimaryBlue) / 238); if (_flMouseAnimationBlue >= Color.Default.MouseSecondaryBlue) { _flMouseAnimationBlue = Color.Default.MouseSecondaryBlue; } } else if (Color.Default.MouseSecondaryBlue < Color.Default.MousePrimaryBlue) { _flMouseAnimationBlue = _flMouseAnimationBlue - ((float)(Color.Default.MousePrimaryBlue - Color.Default.MouseSecondaryBlue) / 238); if (_flMouseAnimationBlue <= Color.Default.MouseSecondaryBlue) { _flMouseAnimationBlue = Color.Default.MouseSecondaryBlue; } } } //resetting values after animation is done else if (_objTimer2 != DateTime.MinValue) { _objTimer2 = DateTime.MinValue; _isAnimationReady = true; } else if (_isAnimationReady) { //highlight the Mouseposition in secondary color HighlightMousePosition(_mouseSecondaryColor); } } }
/// <summary> /// Sets the color of all LEDs on the mouse. /// </summary> /// <param name="color">Color to set.</param> public override void SetAll(Color color) { SetGuid(NativeWrapper.CreateMouseEffect(new Static(Led.All, color))); }
/// <summary> /// Sets the color of a specific LED on the mouse. /// </summary> /// <param name="led">Which LED to modify.</param> /// <param name="color">Color to set.</param> public void SetLed(Led led, Color color) { SetGuid(NativeWrapper.CreateMouseEffect(new Static(led, color))); }
/// <summary> /// Initializes a new instance of the <see cref="Breathing" /> struct using /// the <see cref="BreathingType.Two" /> breathing type. /// </summary> /// <param name="first">Initial color.</param> /// <param name="second">Second color.</param> public Breathing(Color first, Color second) : this(BreathingType.Two, first, second) { }
/// <summary> /// Initializes a new instance of the <see cref="Breathing" /> struct. /// </summary> /// <param name="type">The type of breathing effect.</param> /// <param name="first">Initial color.</param> /// <param name="second">Second color.</param> public Breathing(BreathingType type, Color first, Color second) { Type = type; First = first; Second = second; }
/// <summary> /// Initializes a new instance of the <see cref="Breathing" /> struct. /// </summary> /// <param name="color">Color to breathe with.</param> /// <param name="parameter">Additional effect parameter to set.</param> public Breathing(Color color, int parameter = 0) : this(BreathingType.One, color, Color.Black, parameter) { }
public void rainbowStarlightTimer(Object source, EventArgs e) { if (keyPressesCon.Count > 0) { Random rnd = new Random(); // int maxValue = 500; int decayRate = (maxValue / 50); keyPressesCon[keyPressesCon.Keys.ElementAt(rnd.Next(keyPressesCon.Count)).ToString()] = (int)(maxValue); int i = 0; foreach (int s in keyPressesCon.Values.ToList()) { if (Enum.IsDefined(typeof(Key), keyPressesCon.Keys.ElementAt(i))) { Key newKey = (Key)Enum.Parse(typeof(Key), keyPressesCon.Keys.ElementAt(i), true); if (s > 0) { keyPressesCon[keyPressesCon.Keys.ElementAt(i).ToString()] = s - decayRate; } else if ((s - decayRate) > (maxValue)) { keyPressesCon[keyPressesCon.Keys.ElementAt(i).ToString()] = (int)(maxValue); } else { keyPressesCon[keyPressesCon.Keys.ElementAt(i).ToString()] = 0; if (ledOFFCold) { keyPressesCon[keyPressesCon.Keys.ElementAt(i).ToString()] = 1; } else { keyPressesCon[keyPressesCon.Keys.ElementAt(i).ToString()] = 0; keyboardGrid[newKey] = new ColoreColor(0, 0, 0); i++; continue; } } float fractBetween = 0; float adjValue = ((float)(s) / (float)(maxValue)); if (adjValue <= 0) // accounts for an input <=0 { idx1 = idx2 = 0; } else if (adjValue >= 1) // accounts for an input >=1 { idx1 = idx2 = NUM_COLORS - 1; } else { adjValue = adjValue * (NUM_COLORS - 1); // Will multiply value by 3. idx1 = (int)(Math.Floor(adjValue)); // Our desired color will be after this index. idx2 = idx1 + 1; // ... and before this index (inclusive). fractBetween = adjValue - (float)(idx1); // Distance between the two indexes (0-1). } byte curRColor = (byte)(((curColor[idx2, 0] - curColor[idx1, 0]) * fractBetween + curColor[idx1, 0]) * (255)); byte curGColor = (byte)(((curColor[idx2, 1] - curColor[idx1, 1]) * fractBetween + curColor[idx1, 1]) * (255)); byte curBColor = (byte)(((curColor[idx2, 2] - curColor[idx1, 2]) * fractBetween + curColor[idx1, 2]) * (255)); keyboardGrid[newKey] = new ColoreColor((byte)(curRColor), (byte)(curGColor), (byte)(curBColor)); i++; } } Chroma.Instance.Keyboard.SetCustom(keyboardGrid); } }
public void UintShouldImplicitCastToColor() { var expected = new Color(0x00123456); Color actual = 0x00123456; Assert.AreEqual(expected, actual); }
public void ShouldNotEqualNull() { var c = new Color(255, 255, 255); Assert.AreNotEqual(c, null); Assert.False(c == null); Assert.True(c != null); Assert.False(c.Equals(null)); }
public void ShouldNotEqualDifferentUint() { var a = new Color(255, 0, 255); const uint B = 0x00FFFFFF; Assert.AreNotEqual(a, B); Assert.False(a == B); Assert.True(a != B); }
public void ShouldConstructFromColor() { var c = new Color(0x00123456); Assert.AreEqual(new Color(c), c); }
/// <summary> /// Initializes a new instance of the <see cref="Breathing" /> struct. /// </summary> /// <param name="first">Primary effect color.</param> /// <param name="second">Secondary effect color.</param> /// <param name="parameter">Additional effect parameter to set.</param> public Breathing(Color first, Color second, int parameter = 0) : this(BreathingType.Two, first, second, parameter) { }
/// <summary> /// Sets the color of all components on this device. /// </summary> /// <param name="color">Color to set.</param> public override void SetAll(Color color) { SetGuid(NativeWrapper.CreateKeypadEffect(new Static(color))); }
public void ShouldNotEqualArbitraryObject() { var c = new Color(0); var o = new object(); Assert.AreNotEqual(c, o); Assert.False(c == o); Assert.True(c != o); }
public void UintShouldEqualIdenticalColor() { const uint A = 0x00FFFFFF; var b = new Color(0x00FFFFFF); Assert.AreEqual(A, b); Assert.True(A == b); Assert.False(A != b); }
/// <summary> /// Initializes a new instance of the <see cref="Breathing" /> struct. /// </summary> /// <param name="color">The color to set.</param> public Breathing(Color color) { Color = color; }
/// <summary> /// Initializes a new instance of the <see cref="Static" /> struct. /// </summary> /// <param name="color">Color to set.</param> public Static(Color color) { Color = color; }
public void ShouldImplicitCastToUint() { const uint Expected = 0x00010203; uint actual = new Color(0x00010203); Assert.AreEqual(Expected, actual); }
public void UintShouldNotEqualDifferentColor() { const uint A = 0x00FF00FF; var b = new Color(0x00FFFFFF); Assert.AreNotEqual(A, b); Assert.False(A == b); Assert.True(A != b); }
public void ShouldNotEqualDifferentColor() { var a = new Color(0); var b = new Color(1); Assert.AreNotEqual(a, b); Assert.False(a == b); Assert.True(a != b); }