diff --git a/src/Windows/Perspex.Direct2D1/Media/VisualBrushImpl.cs b/src/Windows/Perspex.Direct2D1/Media/VisualBrushImpl.cs index 13b4d07533..69bcf97737 100644 --- a/src/Windows/Perspex.Direct2D1/Media/VisualBrushImpl.cs +++ b/src/Windows/Perspex.Direct2D1/Media/VisualBrushImpl.cs @@ -46,6 +46,7 @@ namespace Perspex.Direct2D1.Media if (brush.TileMode == TileMode.None) { drawRect = destinationRect; + transform *= Matrix.CreateTranslation(destinationRect.Position); } else { @@ -75,38 +76,31 @@ namespace Perspex.Direct2D1.Media Rect destinationRect, Vector scale) { - if (brush.TileMode == TileMode.None) - { - var x = destinationRect.X; - var y = destinationRect.Y; - var size = sourceRect.Size * scale; - - switch (brush.AlignmentX) - { - case AlignmentX.Center: - x += (destinationRect.Width - size.Width) / 2; - break; - case AlignmentX.Right: - x += destinationRect.Width - size.Width; - break; - } - - switch (brush.AlignmentY) - { - case AlignmentY.Center: - y += (destinationRect.Height - size.Height) / 2; - break; - case AlignmentY.Bottom: - y += destinationRect.Height - size.Height; - break; - } + var x = 0.0; + var y = 0.0; + var size = sourceRect.Size * scale; - return new Vector(x, y); + switch (brush.AlignmentX) + { + case AlignmentX.Center: + x += (destinationRect.Width - size.Width) / 2; + break; + case AlignmentX.Right: + x += destinationRect.Width - size.Width; + break; } - else + + switch (brush.AlignmentY) { - return new Vector(); + case AlignmentY.Center: + y += (destinationRect.Height - size.Height) / 2; + break; + case AlignmentY.Bottom: + y += destinationRect.Height - size.Height; + break; } + + return new Vector(x, y); } public override void Dispose() diff --git a/tests/TestFiles/Direct2D1/Media/VisualBrush/VisualBrush_Tile_Alignment_BottomRight.expected.png b/tests/TestFiles/Direct2D1/Media/VisualBrush/VisualBrush_Tile_Alignment_BottomRight.expected.png new file mode 100644 index 0000000000..0918b7fd51 Binary files /dev/null and b/tests/TestFiles/Direct2D1/Media/VisualBrush/VisualBrush_Tile_Alignment_BottomRight.expected.png differ