private void floatTrackbarControlLuminance_ValueChanged(FloatTrackbarControl _Sender, float _fFormerValue) { float3 HSL = AdobeColors.RGB2HSB((float3)m_RGB); HSL.z = _Sender.Value; RGB = AdobeColors.HSB2RGB(HSL); }
protected void UpdateTextBoxes() { float3 HSL = AdobeColors.RGB2HSB((float3)m_RGB); floatTrackbarControlHue.Value = HSL.x * 360.0f; floatTrackbarControlSaturation.Value = HSL.y; floatTrackbarControlLuminance.Value = HSL.z; floatTrackbarControlRed.Value = m_RGB.x; floatTrackbarControlGreen.Value = m_RGB.y; floatTrackbarControlBlue.Value = m_RGB.z; floatTrackbarControlAlpha.Value = m_RGB.w; // Update RGB gradients Color LDR = ColorLDR; floatTrackbarControlRed.ColorMin = Color.FromArgb(0, LDR.G, LDR.B); floatTrackbarControlRed.ColorMax = Color.FromArgb(LDR.R, LDR.G, LDR.B); floatTrackbarControlGreen.ColorMin = Color.FromArgb(LDR.R, 0, LDR.B); floatTrackbarControlGreen.ColorMax = Color.FromArgb(LDR.R, LDR.G, LDR.B); floatTrackbarControlBlue.ColorMin = Color.FromArgb(LDR.R, LDR.G, 0); floatTrackbarControlBlue.ColorMax = Color.FromArgb(LDR.R, LDR.G, LDR.B); floatTrackbarControlAlpha.ColorMin = Color.FromArgb(128, 0, 0, 0); floatTrackbarControlAlpha.ColorMax = Color.FromArgb(128 + LDR.A / 2, LDR.A, LDR.A, LDR.A); // Update hexa LDR value WriteHexData(m_RGB); }
protected void sliderControlHSL_Scroll(object sender, System.EventArgs e) { m_dontRefresh = DONT_REFRESH.COLOR_SLIDER; RGB = AdobeColors.HSB2RGB(sliderControlHSL.HSL); // Handle special cases where saturation is 0 (shades of gray) and it's not possible to devise a hue // Simply use the hue dictated by the color slider... if (sliderControlHSL.HSL.y < 1e-4f) { float3 TempHSL = AdobeColors.RGB2HSB((float3)m_RGB); TempHSL.x = sliderControlHSL.HSL.x; colorBoxControl.HSL = TempHSL; } }
/// <summary> /// Returns the graphed color at the x,y position on the control /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> protected float3 GetColor(int x, int y) { float InvWidth = 1.0f / (Width - 4); float InvHeight = 1.0f / (Height - 4); float3 Result = float3.One; float3 HSL = this.HSL; switch (m_DrawStyle) { case ColorPickerForm.DRAW_STYLE.Hue: Result.x = HSL.x; Result.y = x * InvWidth; Result.z = 1.0f - y * InvHeight; break; case ColorPickerForm.DRAW_STYLE.Saturation: Result.y = HSL.y; Result.x = x * InvWidth; Result.z = 1.0f - y * InvHeight; break; case ColorPickerForm.DRAW_STYLE.Brightness: Result.z = HSL.z; Result.x = x * InvWidth; Result.y = 1.0f - y * InvHeight; break; case ColorPickerForm.DRAW_STYLE.Red: Result = AdobeColors.RGB2HSB(new float3(m_RGB.x, 1.0f - y * InvHeight, x * InvWidth)); break; case ColorPickerForm.DRAW_STYLE.Green: Result = AdobeColors.RGB2HSB(new float3(1.0f - y * InvHeight, m_RGB.y, x * InvWidth)); break; case ColorPickerForm.DRAW_STYLE.Blue: Result = AdobeColors.RGB2HSB(new float3(x * InvWidth, 1.0f - y * InvHeight, m_RGB.z)); break; } return(Result); }