10 changed files with 157 additions and 45 deletions
@ -0,0 +1,21 @@ |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Avalonia.Media |
|||
{ |
|||
/// <summary>
|
|||
/// A brush that draws with a linear gradient.
|
|||
/// </summary>
|
|||
public interface IGradientBrush : IBrush |
|||
{ |
|||
/// <summary>
|
|||
/// Gets the brush's gradient stops.
|
|||
/// </summary>
|
|||
IReadOnlyList<GradientStop> GradientStops { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the brush's spread method that defines how to draw a gradient that doesn't fill
|
|||
/// the bounds of the destination control.
|
|||
/// </summary>
|
|||
GradientSpreadMethod SpreadMethod { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
namespace Avalonia.Media |
|||
{ |
|||
/// <summary>
|
|||
/// A brush that draws with a linear gradient.
|
|||
/// </summary>
|
|||
public interface ILinearGradientBrush : IGradientBrush |
|||
{ |
|||
/// <summary>
|
|||
/// Gets or sets the start point for the gradient.
|
|||
/// </summary>
|
|||
RelativePoint StartPoint { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the end point for the gradient.
|
|||
/// </summary>
|
|||
RelativePoint EndPoint { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
|
|||
namespace Avalonia.Media.Immutable |
|||
{ |
|||
/// <summary>
|
|||
/// A brush that draws with a gradient.
|
|||
/// </summary>
|
|||
public abstract class ImmutableGradientBrush : IGradientBrush |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="ImmutableGradientBrush"/> class.
|
|||
/// </summary>
|
|||
/// <param name="gradientStops">The gradient stops.</param>
|
|||
/// <param name="opacity">The opacity of the brush.</param>
|
|||
/// <param name="spreadMethod">The spread method.</param>
|
|||
protected ImmutableGradientBrush( |
|||
IReadOnlyList<GradientStop> gradientStops, |
|||
double opacity, |
|||
GradientSpreadMethod spreadMethod) |
|||
{ |
|||
GradientStops = gradientStops; |
|||
Opacity = opacity; |
|||
SpreadMethod = spreadMethod; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="ImmutableGradientBrush"/> class.
|
|||
/// </summary>
|
|||
/// <param name="source">The brush from which this brush's properties should be copied.</param>
|
|||
protected ImmutableGradientBrush(IGradientBrush source) |
|||
: this(source.GradientStops.ToList(), source.Opacity, source.SpreadMethod) |
|||
{ |
|||
|
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
public IReadOnlyList<GradientStop> GradientStops { get; } |
|||
|
|||
/// <inheritdoc/>
|
|||
public double Opacity { get; } |
|||
|
|||
/// <inheritdoc/>
|
|||
public GradientSpreadMethod SpreadMethod { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Avalonia.Media.Immutable |
|||
{ |
|||
/// <summary>
|
|||
/// A brush that draws with a linear gradient.
|
|||
/// </summary>
|
|||
public class ImmutableLinearGradientBrush : ImmutableGradientBrush, ILinearGradientBrush |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="ImmutableGradientBrush"/> class.
|
|||
/// </summary>
|
|||
/// <param name="gradientStops">The gradient stops.</param>
|
|||
/// <param name="opacity">The opacity of the brush.</param>
|
|||
/// <param name="spreadMethod">The spread method.</param>
|
|||
/// <param name="startPoint">The start point for the gradient.</param>
|
|||
/// <param name="endPoint">The end point for the gradient.</param>
|
|||
public ImmutableLinearGradientBrush( |
|||
IReadOnlyList<GradientStop> gradientStops, |
|||
double opacity = 1, |
|||
GradientSpreadMethod spreadMethod = GradientSpreadMethod.Pad, |
|||
RelativePoint? startPoint = null, |
|||
RelativePoint? endPoint = null) |
|||
: base(gradientStops, opacity, spreadMethod) |
|||
{ |
|||
StartPoint = startPoint ?? RelativePoint.TopLeft; |
|||
EndPoint = endPoint ?? RelativePoint.BottomRight; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="ImmutableGradientBrush"/> class.
|
|||
/// </summary>
|
|||
/// <param name="source">The brush from which this brush's properties should be copied.</param>
|
|||
public ImmutableLinearGradientBrush(ILinearGradientBrush source) |
|||
: base(source) |
|||
{ |
|||
StartPoint = source.StartPoint; |
|||
EndPoint = source.EndPoint; |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
public RelativePoint StartPoint { get; } |
|||
|
|||
/// <inheritdoc/>
|
|||
public RelativePoint EndPoint { get; } |
|||
} |
|||
} |
|||
@ -1,47 +1,6 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<DefaultTestTimeout>1000</DefaultTestTimeout> |
|||
<IgnoredTests> |
|||
<NamedTestSelector> |
|||
<TestName>Avalonia.Direct2D1.RenderTests.Media.LinearGradientBrushTests.LinearGradientBrush_RedBlue_Vertical_Fill</TestName> |
|||
</NamedTestSelector> |
|||
<FixtureTestSelector> |
|||
<FixtureName>Avalonia.Direct2D1.RenderTests.Controls.BorderTests</FixtureName> |
|||
</FixtureTestSelector> |
|||
<FixtureTestSelector> |
|||
<FixtureName>Avalonia.Direct2D1.RenderTests.Controls.ImageTests</FixtureName> |
|||
</FixtureTestSelector> |
|||
<FixtureTestSelector> |
|||
<FixtureName>Avalonia.Direct2D1.RenderTests.GeometryClippingTests</FixtureName> |
|||
</FixtureTestSelector> |
|||
<FixtureTestSelector> |
|||
<FixtureName>Avalonia.Direct2D1.RenderTests.Media.FormattedTextImplTests</FixtureName> |
|||
</FixtureTestSelector> |
|||
<FixtureTestSelector> |
|||
<FixtureName>Avalonia.Direct2D1.RenderTests.OpacityMaskTests</FixtureName> |
|||
</FixtureTestSelector> |
|||
<FixtureTestSelector> |
|||
<FixtureName>Avalonia.Direct2D1.RenderTests.Shapes.EllipseTests</FixtureName> |
|||
</FixtureTestSelector> |
|||
<FixtureTestSelector> |
|||
<FixtureName>Avalonia.Direct2D1.RenderTests.Shapes.LineTests</FixtureName> |
|||
</FixtureTestSelector> |
|||
<FixtureTestSelector> |
|||
<FixtureName>Avalonia.Direct2D1.RenderTests.Shapes.PathTests</FixtureName> |
|||
</FixtureTestSelector> |
|||
<FixtureTestSelector> |
|||
<FixtureName>Avalonia.Direct2D1.RenderTests.Shapes.PolygonTests</FixtureName> |
|||
</FixtureTestSelector> |
|||
<FixtureTestSelector> |
|||
<FixtureName>Avalonia.Direct2D1.RenderTests.Shapes.PolylineTests</FixtureName> |
|||
</FixtureTestSelector> |
|||
<FixtureTestSelector> |
|||
<FixtureName>Avalonia.Direct2D1.RenderTests.Shapes.RectangleTests</FixtureName> |
|||
</FixtureTestSelector> |
|||
<NamedTestSelector> |
|||
<TestName>Avalonia.Direct2D1.RenderTests.Media.LinearGradientBrushTests.LinearGradientBrush_RedBlue_Horizontal_Fill</TestName> |
|||
</NamedTestSelector> |
|||
</IgnoredTests> |
|||
<PreviouslyBuiltSuccessfully>True</PreviouslyBuiltSuccessfully> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
Loading…
Reference in new issue