Browse Source

Fix tile alignment.

pull/111/head
Steven Kirk 11 years ago
parent
commit
ec55baf12d
  1. 50
      src/Windows/Perspex.Direct2D1/Media/VisualBrushImpl.cs
  2. BIN
      tests/TestFiles/Direct2D1/Media/VisualBrush/VisualBrush_Tile_Alignment_BottomRight.expected.png

50
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()

BIN
tests/TestFiles/Direct2D1/Media/VisualBrush/VisualBrush_Tile_Alignment_BottomRight.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

Loading…
Cancel
Save