コード例 #1
0
 private void SetCmykColorToSliders(CmykColor cmykColor)
 {
     CmykColorC.Value = cmykColor.C;
     CmykColorM.Value = cmykColor.M;
     CmykColorY.Value = cmykColor.Y;
     CmykColorK.Value = cmykColor.K;
 }
コード例 #2
0
        public CmykColor ConvertToCmykColor()
        {
            double rValueFromZeroToOne = this.R / 255;
            double gValueFromZeroToOne = this.G / 255;
            double bValueFromZeroToOne = this.B / 255;

            var    resultCmykColor = new CmykColor();
            double colorK          = 1 - Math.Max(Math.Max(rValueFromZeroToOne, gValueFromZeroToOne), bValueFromZeroToOne);

            if (Math.Abs(1 - colorK) < 1e-10)
            {
                resultCmykColor.C = 0;
                resultCmykColor.M = 0;
                resultCmykColor.Y = 0;
            }
            else
            {
                resultCmykColor.C = (1 - rValueFromZeroToOne - colorK) / (1 - colorK) * 100;
                resultCmykColor.M = (1 - gValueFromZeroToOne - colorK) / (1 - colorK) * 100;
                resultCmykColor.Y = (1 - bValueFromZeroToOne - colorK) / (1 - colorK) * 100;
            }

            resultCmykColor.K = colorK * 100;

            return(resultCmykColor);
        }
コード例 #3
0
        private void CmykColorSlider_OnValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            if (_loading)
            {
                return;
            }

            var cmykColor = new CmykColor(CmykColorC.Value, CmykColorM.Value, CmykColorY.Value, CmykColorK.Value);

            _loading = true;
            SetRgbColorToColorPicker(cmykColor.ConvertToRgbColor());
            SetHsvColorToSliders(cmykColor.ConvertToHsvColor());
            SetLabColorToSliders(cmykColor.ConvertToLabColor());
            _loading = false;
        }