BrushCreateLinearGradient(PointF, PointF, Color64, Color64, GradientWrapMode, WorkingColorSpace) Method

Creates a linear gradient Brush that blends from one color to another along a straight line specified by startPoint and endPoint.
See the Examples section of the GradientWrapMode enumeration for image examples.

Definition

Namespace: KGySoft.Drawing.Shapes
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 10.0.0-rc.1
C#
public static Brush CreateLinearGradient(
	PointF startPoint,
	PointF endPoint,
	Color64 startColor,
	Color64 endColor,
	GradientWrapMode wrapMode = GradientWrapMode.Stop,
	WorkingColorSpace workingColorSpace = WorkingColorSpace.Default
)

Parameters

startPoint  PointF
The starting point of the gradient.
endPoint  PointF
The end point of the gradient.
startColor  Color64
The starting color of the gradient.
endColor  Color64
The end color of the gradient.
wrapMode  GradientWrapMode  (Optional)
Determines how the gradient is treated outside the gradient area. This parameter is optional.
Default value: Stop.
workingColorSpace  WorkingColorSpace  (Optional)
Determines the color space in which the gradient is calculated. This parameter is optional.
Default value: Default, which means Srgb for this overload.

Return Value

Brush
A linear gradient Brush that uses the specified parameters.

Remarks

This overload creates a gradient with fix coordinates. To automatically apply the gradient to the bounds of each Path, use the overloads with an angle parameter, such as the CreateLinearGradient(Single, Color32, Color32, WorkingColorSpace) overload.

The workingColorSpace parameter affects only the color interpolation, not the blending with the background, which is determined by the color space of the target bitmap data (or by DrawingOptions.Quantizer, if specified).

In this overload the default value of workingColorSpace maps to WorkingColorSpace.Srgb, because the Color64 type represents a color in the sRGB color space. When creating a monochromatic gradient, specifying Srgb can be better, because then the perceived mid-tone brightness will be at the middle of the gradient. Otherwise, using Linear may be more appropriate, so the transition between the colors will seem more "natural".

See Also