System.Drawing.Drawing2D.LinearGradientBrush.SetBlendTriangularShape C# (CSharp) Method

SetBlendTriangularShape() public method

public SetBlendTriangularShape ( float focus, float scale ) : void
focus float
scale float
return void
        public void SetBlendTriangularShape(float focus, float scale)
        {
            if (focus < 0 || focus > 1 || scale < 0 || scale > 1)
                throw new ArgumentException ("Invalid parameter passed.");

            blend = new Blend(3);
            blend.Positions[1] = focus;
            blend.Positions[2] = 1.0f;

            blend.Factors[1] = scale;

            changed = true;
        }

Same methods

LinearGradientBrush::SetBlendTriangularShape ( float focus ) : void

Usage Example

コード例 #1
0
        /// <summary> Method is called whenever this form is resized. </summary>
        /// <param name="e"></param>
        /// <remarks> This redraws the background of this form </remarks>
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);

            // Get rid of any current background image
            if (BackgroundImage != null)
            {
                BackgroundImage.Dispose();
                BackgroundImage = null;
            }

            if (ClientSize.Width > 0)
            {
                // Create the items needed to draw the background
                Bitmap image = new Bitmap(ClientSize.Width, ClientSize.Height);
                Graphics gr = Graphics.FromImage(image);
                Rectangle rect = new Rectangle(new Point(0, 0), ClientSize);

                // Create the brush
                LinearGradientBrush brush = new LinearGradientBrush(rect, SystemColors.Control, ControlPaint.Dark(SystemColors.Control), LinearGradientMode.Vertical);
                brush.SetBlendTriangularShape(0.33F);

                // Create the image
                gr.FillRectangle(brush, rect);
                gr.Dispose();

                // Set this as the backgroundf
                BackgroundImage = image;
            }
        }
All Usage Examples Of System.Drawing.Drawing2D.LinearGradientBrush::SetBlendTriangularShape