committed by
GitHub
19 changed files with 285 additions and 21 deletions
@ -0,0 +1,71 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" |
|||
x:Class="RenderDemo.Pages.BrushesPage"> |
|||
<Canvas Background="White" Width="480" Height="360"> |
|||
<Rectangle Canvas.Left="20" Canvas.Top="20" Width="440" Height="50"> |
|||
<Rectangle.Fill> |
|||
<LinearGradientBrush StartPoint="0,0" EndPoint="410,0"> |
|||
<LinearGradientBrush.Transform> |
|||
<TransformGroup> |
|||
<ScaleTransform ScaleX="0.5" /> |
|||
<SkewTransform /> |
|||
<RotateTransform /> |
|||
<TranslateTransform X="5" Y="15" /> |
|||
</TransformGroup> |
|||
</LinearGradientBrush.Transform> |
|||
<LinearGradientBrush.GradientStops> |
|||
<GradientStop Color="Blue" Offset="0" /> |
|||
<GradientStop Color="Green" Offset="0.5" /> |
|||
<GradientStop Color="Lime" Offset="1" /> |
|||
</LinearGradientBrush.GradientStops> |
|||
</LinearGradientBrush> |
|||
</Rectangle.Fill> |
|||
</Rectangle> |
|||
<TextBlock Canvas.Left="20" Canvas.Top="70" FontSize="30" Text="scale(0.5) on gradient" /> |
|||
<Rectangle Canvas.Left="20" Canvas.Top="110" Width="440" Height="50"> |
|||
<Rectangle.Fill> |
|||
<RadialGradientBrush Center="0.0,0.0" GradientOrigin="0.0,0.0" Radius="0.13636364"> |
|||
<RadialGradientBrush.Transform> |
|||
<TransformGroup> |
|||
<ScaleTransform /> |
|||
<SkewTransform AngleX="45" /> |
|||
<RotateTransform /> |
|||
<TranslateTransform X="240" Y="45" /> |
|||
</TransformGroup> |
|||
</RadialGradientBrush.Transform> |
|||
<RadialGradientBrush.GradientStops> |
|||
<GradientStop Color="Black" Offset="0" /> |
|||
<GradientStop Color="#FFFFA500" Offset="1" /> |
|||
</RadialGradientBrush.GradientStops> |
|||
</RadialGradientBrush> |
|||
</Rectangle.Fill> |
|||
</Rectangle> |
|||
<TextBlock Canvas.Left="20" Canvas.Top="160" FontSize="30" Text="skewX(45) on gradient" /> |
|||
<Rectangle Canvas.Left="20" Canvas.Top="210" Width="440" Height="50"> |
|||
<Rectangle.Fill> |
|||
<VisualBrush TileMode="Tile" SourceRect="0,0,20,20" DestinationRect="0,0,20,20" Stretch="None"> |
|||
<VisualBrush.Transform> |
|||
<TransformGroup> |
|||
<ScaleTransform ScaleX="2" ScaleY="2" /> |
|||
<SkewTransform AngleX="45" /> |
|||
<RotateTransform /> |
|||
<TranslateTransform X="5" Y="5" /> |
|||
</TransformGroup> |
|||
</VisualBrush.Transform> |
|||
<VisualBrush.Visual> |
|||
<Canvas Width="20" Height="20"> |
|||
<Rectangle Canvas.Left="0" Canvas.Top="0" Width="10" Height="10" Fill="Maroon" /> |
|||
<Rectangle Canvas.Left="10" Canvas.Top="0" Width="10" Height="10" Fill="Green" /> |
|||
<Rectangle Canvas.Left="0" Canvas.Top="10" Width="10" Height="10" Fill="Blue" /> |
|||
<Rectangle Canvas.Left="10" Canvas.Top="10" Width="10" Height="10" Fill="Yellow" /> |
|||
</Canvas> |
|||
</VisualBrush.Visual> |
|||
</VisualBrush> |
|||
</Rectangle.Fill> |
|||
</Rectangle> |
|||
<TextBlock Canvas.Left="20" Canvas.Top="260" FontSize="30" Text="scale(2), skewX(45) on pattern" /> |
|||
</Canvas> |
|||
</UserControl> |
|||
@ -0,0 +1,18 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace RenderDemo.Pages; |
|||
|
|||
public class BrushesPage : UserControl |
|||
{ |
|||
public BrushesPage() |
|||
{ |
|||
InitializeComponent(); |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,21 @@ |
|||
using Avalonia.VisualTree; |
|||
|
|||
namespace Avalonia.Media.Immutable |
|||
{ |
|||
/// <summary>
|
|||
/// Represents a transform on an <see cref="IVisual"/>.
|
|||
/// </summary>
|
|||
public class ImmutableTransform : ITransform |
|||
{ |
|||
public Matrix Value { get; } |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="ImmutableTransform"/> class.
|
|||
/// </summary>
|
|||
/// <param name="matrix">The transform matrix.</param>
|
|||
public ImmutableTransform(Matrix matrix) |
|||
{ |
|||
Value = matrix; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
using System; |
|||
using Avalonia.Media.Immutable; |
|||
|
|||
namespace Avalonia.Media |
|||
{ |
|||
/// <summary>
|
|||
/// Extension methods for transform classes.
|
|||
/// </summary>
|
|||
public static class TransformExtensions |
|||
{ |
|||
/// <summary>
|
|||
/// Converts a transform to an immutable transform.
|
|||
/// </summary>
|
|||
/// <param name="transform">The transform.</param>
|
|||
/// <returns>
|
|||
/// The result of calling <see cref="Transform.ToImmutable"/> if the transform is mutable,
|
|||
/// otherwise <paramref name="transform"/>.
|
|||
/// </returns>
|
|||
public static ImmutableTransform ToImmutable(this ITransform transform) |
|||
{ |
|||
_ = transform ?? throw new ArgumentNullException(nameof(transform)); |
|||
|
|||
return (transform as Transform)?.ToImmutable() ?? new ImmutableTransform(transform.Value); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue