/// <summary> /// Called when the hex field updates /// </summary> /// <param name="evt"></param> private void UpdateColorFromHex(FocusOutEvent evt) { UpdatePrevColor(); // make sure the color string starts with a # string colorString = _hexField.value; if (!colorString.StartsWith("#")) { colorString = colorString.Insert(0, "#"); } // if the string is not valid, reset to the previous color if (!UnityEngine.ColorUtility.TryParseHtmlString(colorString, out Color colorFromHex)) { _hexField.SetValueWithoutNotify(UnityEngine.ColorUtility.ToHtmlStringRGB(_currentColor)); return; } // set color _currentColor = colorFromHex; // update display UpdateColorComparisionSwatch(); UpdateHslWheel(); UpdateSliders(); OnColorChanged?.Invoke(_currentColor); }
public void UpdatePicker(IColorable currentSelectable) { if (currentSelectable == null) { return; } if (currentSelectable.ColorFillArea) { _currentColor = currentSelectable.GetInlineAreaColor(); } else { _currentColor = currentSelectable.GetPathColor(); } _alpha.value = _currentColor.a; Color.RGBToHSV(_currentColor, out _currentHue, out _currentSaturation, out _currentValue); float hue = 360 * _currentHue; Vector2 direction = CurveMath.Rotate(Vector2.right, hue); _hueSelector.localPosition = direction.normalized * _hueRadius; _image.color = Color.HSVToRGB(_currentHue, 1, 1); Vector2 newPositon; newPositon.x = _currentSaturation * _svRectWidth - _saturationValueRectWidth; newPositon.y = _currentValue * _svRectWidth - _saturationValueRectWidth; _colorSelector.localPosition = newPositon; OnColorChanged?.Invoke(currentSelectable.GetInlineAreaColor(), currentSelectable.GetPathColor()); }
void ChangeColor()//puts the first color of the queue in the last place and sets it as the "currentColor" { AgentType color = colors.Dequeue(); currentColor = color; colors.Enqueue(color); OnColorChanged.Invoke(); }
private void onChangePrefixColor(UIComponent component, Color selectedColor) { if (!isChanging && m_prefixSelector.selectedIndex >= 0) { extension.SetColor((uint)m_prefixSelector.selectedIndex, selectedColor); } eventOnColorChange?.Invoke(selectedColor); }
/// <summary> /// Called when the alpha slider updates /// </summary> /// <param name="evt"></param> private void UpdateAlpha(ChangeEvent <float> evt) { _currentColor.a = evt.newValue; // update display UpdateColorComparisionSwatch(); OnColorChanged?.Invoke(_currentColor); }
// // Private Methods // private void UpdateColor(Color c) { Color = c; // Update color sample colorSample.color = c; OnColorChanged?.Invoke(c); }
public virtual void ChangeColor(MyColor newColor) { (PressColor = newColor.Duplicate()).AdjustLight(-0.6f); DefaultColor = newColor.Duplicate(); ColorChanger.SetColor(newColor); ScreenTexture.ColorChanger.ResetColor(newColor); OnColorChanged?.Invoke(newColor); }
private void ToggleClicked(ColorToggle toggle) { if (toggle == currentToggle) { return; } Select(toggle); OnColorChanged?.Invoke(currentToggle.color); }
/// <summary> /// All the common updating after a slider changed /// </summary> private void DoCommonUpdateFromSliders() { // update display UpdateColorComparisionSwatch(); UpdateHslWheel(); UpdateAlphaSlider(); UpdateHexColor(); OnColorChanged?.Invoke(_currentColor); }
private void UpdateColorFromHSB() { color = Color.HSVToRGB(hsb.x, hsb.y, hsb.z); // Calculate Luma var Y = 0.2126f * color.r + 0.7152f * color.g + 0.0722f * color.b; // Update selector's color (black or white) selector.color = Y > 0.5f? Color.black : Color.white; OnColorChanged?.Invoke(color); }
private void SetImageColor(Color value) { if (spriteRenderer != null) { spriteRenderer.color = value; } else if (image != null) { image.color = value; } OnColorChanged?.Invoke(value); }
/// <summary> /// Sets the current color and updates all displays /// </summary> /// <param name="newColor"></param> public void SetColor(Color newColor) { UpdatePrevColor(); _currentColor = newColor; // update display UpdateColorComparisionSwatch(); UpdateHslWheel(); UpdateSliders(); UpdateHexColor(); OnColorChanged?.Invoke(_currentColor); }
// ######################## FUNCTIONALITY ######################## // #region FUNCTIONALITY #region EVENT_HANDLING /// <summary> /// Called when the hsl wheel updates /// </summary> /// <param name="newColor"></param> private void UpdateColorFromHslWheel(Color newColor) { UpdatePrevColor(); // make sure alpha is kept and set the color newColor.a = _currentColor.a; _currentColor = newColor; // update display UpdateColorComparisionSwatch(); UpdateSliders(); UpdateHexColor(); OnColorChanged?.Invoke(_currentColor); }
private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { if (!isTextHex) { int red = (int)slRed.Value; int green = (int)slGreen.Value; int blue = (int)slBlue.Value; Color color = Color.FromArgb(red, green, blue); hexColor = ColorTranslator.ToHtml(color); tbHex.Text = hexColor; } OnColorChanged?.Invoke(sender, hexColor); }
/* Select Saturation : the intensity of the color and * Brightness (or Value) : the brightness of the color * Rectangle in the center of Texture */ void SetSaturationAndValue(Vector2 pickPosition) { // position SaturationAndValueSelector pickPosition.x = Mathf.Clamp(pickPosition.x, -_saturationValueRectWidth, _saturationValueRectWidth); pickPosition.y = Mathf.Clamp(pickPosition.y, -_saturationValueRectWidth, _saturationValueRectWidth); _colorSelector.localPosition = pickPosition; // Set ColorSelectorImage Color _currentSaturation = (pickPosition.x + _saturationValueRectWidth) / _svRectWidth; _currentValue = (pickPosition.y + _saturationValueRectWidth) / _svRectWidth; _currentColor = Color.HSVToRGB(_currentHue, _currentSaturation, _currentValue); OnColorChanged?.Invoke(_currentColor); }
public void SelectRandom() { if (colorToggles.Count == 0) { return; } ColorToggle toggle = colorToggles[Random.Range(0, colorToggles.Count)]; if (toggle == currentToggle) { return; } Select(toggle); OnColorChanged?.Invoke(currentToggle.color); }
private void Button_Click(object sender, EventArgs e) { var dialog = new ColorDialog() { Color = color }; if (dialog.ShowDialog(this) == DialogResult.OK) { color = dialog.Color; RefreshColor(); OnColorChanged?.Invoke(this, new ColorChangedEventArgs() { Color = color }); } }
// Select Hue : the color type; outer circle in Texture void SetHue(Vector2 pickPosition) { // position HueSelector _hueSelector.localPosition = pickPosition.normalized * _hueRadius; pickPosition = _hueSelector.localPosition; float angle = Vector2.Angle(pickPosition, Vector2.right); // Set ColorSelectorImage Color if (pickPosition.y < 0) { angle = 360 - angle; } _currentHue = angle / 360; _image.color = Color.HSVToRGB(_currentHue, 1, 1); _currentColor = Color.HSVToRGB(_currentHue, _currentSaturation, _currentValue); OnColorChanged?.Invoke(_currentColor); }
private void Grid_MouseDown(object sender, MouseButtonEventArgs e) { if (e.ClickCount > 1) { e.Handled = true; ColorPicker cp = new ColorPicker(System.Drawing.Color.FromArgb((int)(color.W * 255), (int)(color.X * 255), (int)(color.Y * 255), (int)(color.Z * 255))); cp.ShowDialog(); if (cp.DialogResult == true) { var c = cp.Selected; SetColor(c); if (OnColorChanged != null) { OnColorChanged.Invoke(); } } } }
public void NotifyColorChanged(Color c, int x, int y) { OnColorChanged?.Invoke(c, x, y); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SelectedIndexChanged(object sender, EventArgs e) { OnColorChanged?.Invoke(sender, e); }
public void SetAlpha() { _currentColor.a = _alpha.value; OnColorChanged?.Invoke(_currentColor); }
void OnValueChanged(int val) { colorDisplay.color = new Color32((byte)R.GetValue(), (byte)G.GetValue(), (byte)B.GetValue(), 255); OnColorChanged?.Invoke(colorDisplay.color); }