From ec55baf12d714eec861bf092f37e2d5331429563 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 4 Sep 2015 18:57:25 +0200 Subject: [PATCH] Fix tile alignment. --- .../Media/VisualBrushImpl.cs | 50 ++++++++---------- ...sh_Tile_Alignment_BottomRight.expected.png | Bin 0 -> 928 bytes 2 files changed, 22 insertions(+), 28 deletions(-) create mode 100644 tests/TestFiles/Direct2D1/Media/VisualBrush/VisualBrush_Tile_Alignment_BottomRight.expected.png 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 0000000000000000000000000000000000000000..0918b7fd511a807b03c40468527b049a248172d0 GIT binary patch literal 928 zcmeAS@N?(olHy`uVBq!ia0vp^CqS5k4M?tyST_$yF%}28J29*~C-V}>VM%xNb!1@J z*w6hZk(Ggg*~`<#F{C2y?OoeGo&dpA`H+TBqo|&JE-Y8D~ZrASq>__)${f~;9j@?i5eel-B-zf2O z&9>Vo=cd%}&6|DtbJ4k~IUBT3*=<|C-?i+0b9MCRZx5ak8z}H@kI78`pVd!2uRYoO z<+RHA?QDu5?zHiXBotE~evZgw{efmG`Q}HJKou4fJe&k3^ z`fqm9_SC#wwYs+rqAXn6C;r*I5`D69L(_qJ2bw2`#zWihyzAHBQM<3^v@RsQZz#3+ Y!>exB`>J;H%|{?1Pgg&ebxsLQ00#PR6#xJL literal 0 HcmV?d00001