LinearGradientBrush.SetBlendTriangularShape Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates a linear gradient with a center color and a linear falloff to a single color on both ends.
Overloads
SetBlendTriangularShape(Single) |
Creates a linear gradient with a center color and a linear falloff to a single color on both ends. |
SetBlendTriangularShape(Single, Single) |
Creates a linear gradient with a center color and a linear falloff to a single color on both ends. |
SetBlendTriangularShape(Single)
- Source:
- LinearGradientBrush.cs
- Source:
- LinearGradientBrush.cs
- Source:
- LinearGradientBrush.cs
- Source:
- LinearGradientBrush.cs
- Source:
- LinearGradientBrush.cs
Creates a linear gradient with a center color and a linear falloff to a single color on both ends.
public:
void SetBlendTriangularShape(float focus);
public void SetBlendTriangularShape (float focus);
member this.SetBlendTriangularShape : single -> unit
Public Sub SetBlendTriangularShape (focus As Single)
Parameters
- focus
- 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).
Examples
For an example, see SetBlendTriangularShape.
Remarks
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.
Applies to
SetBlendTriangularShape(Single, Single)
- Source:
- LinearGradientBrush.cs
- Source:
- LinearGradientBrush.cs
- Source:
- LinearGradientBrush.cs
- Source:
- LinearGradientBrush.cs
- Source:
- LinearGradientBrush.cs
Creates a linear gradient with a center color and a linear falloff to a single color on both ends.
public:
void SetBlendTriangularShape(float focus, float scale);
public void SetBlendTriangularShape (float focus, float scale);
member this.SetBlendTriangularShape : single * single -> unit
Public Sub SetBlendTriangularShape (focus As Single, scale As Single)
Parameters
- focus
- 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
- Single
A value from 0 through1 that specifies how fast the colors falloff from the starting color to focus
(ending color)
Examples
The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e
, 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 );
}
private void SetBlendTriangularShapeExample(PaintEventArgs e)
{
// Create a LinearGradientBrush.
Rectangle myRect = new Rectangle(20, 20, 200, 100);
LinearGradientBrush myLGBrush = new 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);
}
Public Sub SetBlendTriangularShapeExample(ByVal e As PaintEventArgs)
' Create a LinearGradientBrush.
Dim myRect As New Rectangle(20, 20, 200, 100)
Dim myLGBrush As New 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(0.5F, 1.0F)
' Use the triangular brush to draw a second ellipse.
myRect.Y = 150
e.Graphics.FillEllipse(myLGBrush, myRect)
End Sub
Remarks
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.