You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A gradient is the gradual blending from one color to another.
But, hey, why gradients?
Mobile design trends have changed rapidly in recent years, with some things disappearing for a while and then making a gradual comeback. That’s the case with gradients. Gradients are making a comeback.
Defines objects used to paint graphical objects. Classes that derive from Brush describe how the area is painted.
publicabstractclassBrush:BindableObject{}
SolidColorBrush
A SolidColorBrush paints an area with a solid Color.
public class SolidColorBrush : Brush
{
public SolidColorBrush() { }
public SolidColorBrush(Color color)
{
Color = color;
}
public static readonly BindableProperty ColorProperty = BindableProperty.Create(
nameof(Color), typeof(Color), typeof(SolidColorBrush), Color.Default);
public Color Color
{
get => (Color)GetValue(ColorProperty);
set => SetValue(ColorProperty, value);
}
}
NOTE: For convenience, the Brushes class provides a set of commonly used SolidColorBrush objects, such as Blue and Yellow.
GradientBrush
A gradient brush paints an area with multiple colors that blend into each other along an axis.
The GradientBrush definition:
This would allow gradients to be used as background in any control, although the BackgroundColor property would still exist (deprecated).
LinearGradientBrush
A LinearGradientBrush paints an area with a gradient that's defined along a line. This line is called the gradient axis.
You specify the gradient's colors and their locations along the gradient axis using GradientStop objects. By default, the gradient axis runs from the upper left corner to the lower right corner of the area that the brush paints, resulting in a diagonal shading.
A radial gradient brush paints an area with a radial gradient that has a circle, along with a focal point, to define the gradient behavior. The focal point defines the center of the gradient and has default value 0.0.
Brushes
A gradient is the gradual blending from one color to another.
But, hey, why gradients?
Mobile design trends have changed rapidly in recent years, with some things disappearing for a while and then making a gradual comeback. That’s the case with gradients. Gradients are making a comeback.
API
Next, the Brushes API definition.
NOTE: This API definition is based on WPF Brushes API: https://docs.microsoft.com/en-us/dotnet/framework/wpf/graphics-multimedia/wpf-brushes-overview
Brush
Defines objects used to paint graphical objects. Classes that derive from Brush describe how the area is painted.
SolidColorBrush
A SolidColorBrush paints an area with a solid Color.
NOTE: For convenience, the Brushes class provides a set of commonly used SolidColorBrush objects, such as Blue and Yellow.
GradientBrush
A gradient brush paints an area with multiple colors that blend into each other along an axis.
The GradientBrush definition:
The GradientStop is the basic building block of a gradient brush. A gradient stop specifies a Color at an Offset along the gradient axis.
We will add a new property to
IView
to define the background using Brushes.This would allow gradients to be used as background in any control, although the BackgroundColor property would still exist (deprecated).
LinearGradientBrush
A LinearGradientBrush paints an area with a gradient that's defined along a line. This line is called the gradient axis.
You specify the gradient's colors and their locations along the gradient axis using GradientStop objects. By default, the gradient axis runs from the upper left corner to the lower right corner of the area that the brush paints, resulting in a diagonal shading.
RadialGradientBrush
A radial gradient brush paints an area with a radial gradient that has a circle, along with a focal point, to define the gradient behavior. The focal point defines the center of the gradient and has default value 0.0.
Scenarios
Let's take a look at a simple sample:
XAML
CSS
(see #7374)
Scope
The
Background
property will be available in all the views.Difficulty : Medium
The text was updated successfully, but these errors were encountered: