committed by
GitHub
35 changed files with 330 additions and 64 deletions
@ -0,0 +1,21 @@ |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Avalonia.Media |
|||
{ |
|||
/// <summary>
|
|||
/// A brush that draws with a 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,24 @@ |
|||
namespace Avalonia.Media |
|||
{ |
|||
/// <summary>
|
|||
/// Paints an area with a radial gradient.
|
|||
/// </summary>
|
|||
public interface IRadialGradientBrush : IGradientBrush |
|||
{ |
|||
/// <summary>
|
|||
/// Gets the start point for the gradient.
|
|||
/// </summary>
|
|||
RelativePoint Center { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the location of the two-dimensional focal point that defines the beginning of the
|
|||
/// gradient.
|
|||
/// </summary>
|
|||
RelativePoint GradientOrigin { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the horizontal and vertical radius of the outermost circle of the radial gradient.
|
|||
/// </summary>
|
|||
double Radius { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
namespace Avalonia.Media |
|||
{ |
|||
/// <summary>
|
|||
/// A brush which displays a repeating image.
|
|||
/// </summary>
|
|||
public interface ITileBrush : IBrush |
|||
{ |
|||
/// <summary>
|
|||
/// Gets the horizontal alignment of a tile in the destination.
|
|||
/// </summary>
|
|||
AlignmentX AlignmentX { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the horizontal alignment of a tile in the destination.
|
|||
/// </summary>
|
|||
AlignmentY AlignmentY { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the rectangle on the destination in which to paint a tile.
|
|||
/// </summary>
|
|||
RelativeRect DestinationRect { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the rectangle of the source image that will be displayed.
|
|||
/// </summary>
|
|||
RelativeRect SourceRect { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets a value indicating how the source rectangle will be stretched to fill the
|
|||
/// destination rect.
|
|||
/// </summary>
|
|||
Stretch Stretch { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the brush's tile mode.
|
|||
/// </summary>
|
|||
TileMode TileMode { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using Avalonia.VisualTree; |
|||
|
|||
namespace Avalonia.Media |
|||
{ |
|||
/// <summary>
|
|||
/// Paints an area with an <see cref="IVisual"/>.
|
|||
/// </summary>
|
|||
public interface IVisualBrush : ITileBrush |
|||
{ |
|||
/// <summary>
|
|||
/// Gets the visual to draw.
|
|||
/// </summary>
|
|||
IVisual Visual { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using Avalonia.Media.Imaging; |
|||
|
|||
namespace Avalonia.Media |
|||
{ |
|||
/// <summary>
|
|||
/// Paints an area with an <see cref="IBitmap"/>.
|
|||
/// </summary>
|
|||
public interface IImageBrush : ITileBrush |
|||
{ |
|||
/// <summary>
|
|||
/// Gets the image to draw.
|
|||
/// </summary>
|
|||
IBitmap Source { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using Xunit; |
|||
|
|||
namespace Avalonia.Visuals.UnitTests |
|||
{ |
|||
public class RectTests |
|||
{ |
|||
[Fact] |
|||
public void Union_Should_Return_Correct_Value_For_Intersecting_Rects() |
|||
{ |
|||
var result = new Rect(0, 0, 100, 100).Union(new Rect(50, 50, 100, 100)); |
|||
|
|||
Assert.Equal(new Rect(0, 0, 150, 150), result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Union_Should_Return_Correct_Value_For_NonIntersecting_Rects() |
|||
{ |
|||
var result = new Rect(0, 0, 100, 100).Union(new Rect(150, 150, 100, 100)); |
|||
|
|||
Assert.Equal(new Rect(0, 0, 250, 250), result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Union_Should_Ignore_Empty_This_rect() |
|||
{ |
|||
var result = new Rect(0, 0, 0, 0).Union(new Rect(150, 150, 100, 100)); |
|||
|
|||
Assert.Equal(new Rect(150, 150, 100, 100), result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Union_Should_Ignore_Empty_Other_rect() |
|||
{ |
|||
var result = new Rect(0, 0, 100, 100).Union(new Rect(150, 150, 0, 0)); |
|||
|
|||
Assert.Equal(new Rect(0, 0, 100, 100), result); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using Xunit; |
|||
|
|||
namespace Avalonia.Visuals.UnitTests |
|||
{ |
|||
public class SizeTests |
|||
{ |
|||
[Fact] |
|||
public void Should_Produce_Correct_Aspect_Ratio() |
|||
{ |
|||
var result = new Size(3, 2).AspectRatio; |
|||
|
|||
Assert.Equal(1.5, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Dividing_Should_Produce_Scaling_Factor() |
|||
{ |
|||
var result = new Size(15, 10) / new Size(5, 5); |
|||
|
|||
Assert.Equal(new Vector(3, 2), result); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue