LinearGradientBrush::SetBlendTriangularShape Method (Single, Single)
Creates a linear gradient with a center color and a linear falloff to a single color on both ends.
Assembly: System.Drawing (in System.Drawing.dll)
Parameters
- focus
-
Type:
System::Single
A value from 0 through 1 that specifies the center of the gradient (the point where the gradient is composed of only the ending color).
- scale
-
Type:
System::Single
A value from 0 through1 that specifies how fast the colors falloff from the starting color to focus (ending color)
This method specifies a focus, which is the point where the gradient is composed only of the ending color. The focus parameter represents a location as a proportion of the distance along the gradient line. The gradient falls off to the starting color linearly to either side.
The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. The code performs the following actions:
Creates a new LinearGradientBrush.
Uses this brush to draw an ellipse to the screen that has a linear, left-to-right transition of colors.
Transforms the LinearGradientBrush into a triangular shape with its peak in the center.
Draws a second ellipse to the screen using the transformed brush.
Notice that the gradient of the lower ellipse transitions from blue to red and then back to blue.
private: void SetBlendTriangularShapeExample( PaintEventArgs^ e ) { // Create a LinearGradientBrush. Rectangle myRect = Rectangle(20,20,200,100); LinearGradientBrush^ myLGBrush = gcnew LinearGradientBrush( myRect,Color::Blue,Color::Red,0.0f,true ); // Draw an ellipse to the screen using the LinearGradientBrush. e->Graphics->FillEllipse( myLGBrush, myRect ); // Create a triangular shaped brush with the peak at the center // of the drawing area. myLGBrush->SetBlendTriangularShape( .5f, 1.0f ); // Use the triangular brush to draw a second ellipse. myRect.Y = 150; e->Graphics->FillEllipse( myLGBrush, myRect ); }
Available since 1.1