AdvancedColorPicker.SaturationBrightnessPickerView.Draw C# (CSharp) Method

Draw() public method

public Draw ( RectangleF rect ) : void
rect System.Drawing.RectangleF
return void
        public override void Draw(RectangleF rect)
        {
            //Stopwatch s = new Stopwatch();
            //s.Start();

            //Console.WriteLine (" ----- SatBrightPickerView Draw");

            CGContext context = UIGraphics.GetCurrentContext ();

            CGColor[] gradColors = new CGColor[] {UIColor.FromHSBA(hue,1,1,1).CGColor,new CGColor(1,1,1,1)};
            float[] gradLocations = new float[] { 0.0f, 1.0f };

            var colorSpace = CGColorSpace.CreateDeviceRGB ();

            CGGradient gradient = new CGGradient (colorSpace, gradColors, gradLocations);
            context.DrawLinearGradient(gradient,new PointF(rect.Size.Width,0),new PointF(0,0),CGGradientDrawingOptions.DrawsBeforeStartLocation);

            gradColors = new CGColor[] {new CGColor(0,0,0,0), new CGColor(0,0,0,1)};

            gradient = new CGGradient(colorSpace,gradColors, gradLocations);
            context.DrawLinearGradient(gradient,new PointF(0,0),new PointF(0,rect.Size.Height),CGGradientDrawingOptions.DrawsBeforeStartLocation);

            gradient.Dispose();
            colorSpace.Dispose();

            //s.Stop();
            //Console.WriteLine("-----> SatBright Draw time: " + s.Elapsed.ToString());
        }