protected override void SetBackgroundColor(Color color) { if (Control == null) { return; } if (s_currentColorFilter == null && color.IsDefault) { return; } if (color.IsDefault) { Control.ContentFilters = new CIFilter[0]; } var newColor = Element.BackgroundColor.ToNSColor(); if (Equals(s_currentColor, newColor)) { return; } s_currentColor = newColor; s_currentColorFilter = new CIColorPolynomial { RedCoefficients = new CIVector(s_currentColor.RedComponent), BlueCoefficients = new CIVector(s_currentColor.BlueComponent), GreenCoefficients = new CIVector(s_currentColor.GreenComponent) }; Control.ContentFilters = new CIFilter[] { s_currentColorFilter }; }
void UpdateColor() { var color = Element.Color; if (s_currentColorFilter == null && color.IsDefault) { return; } if (color.IsDefault) { Control.ContentFilters = new CIFilter[0]; } var newColor = Element.Color.ToNSColor(); if (Equals(s_currentColor, newColor)) { return; } s_currentColor = newColor; s_currentColorFilter = new CIColorPolynomial { RedCoefficients = new CIVector(s_currentColor.RedComponent), BlueCoefficients = new CIVector(s_currentColor.BlueComponent), GreenCoefficients = new CIVector(s_currentColor.GreenComponent) }; Control.ContentFilters = new CIFilter[] { s_currentColorFilter }; }
/// <summary> /// Applies a Color Polynomial to each pixel of of an image. /// </summary> /// <returns>The altered image.</returns> public CIImage ColorPolynomial() { var color_polynomial = new CIColorPolynomial () { Image = flower, RedCoefficients = new CIVector (0, 0, 0, .4f), GreenCoefficients = new CIVector (0, 0, .5f, .8f), BlueCoefficients = new CIVector (0, 0, .5f, 1), AlphaCoefficients = new CIVector (0, 1, 1, 1), }; return color_polynomial.OutputImage; }