本文整理汇总了C#中Canvas.GetInnerCanvas方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.GetInnerCanvas方法的具体用法?C# Canvas.GetInnerCanvas怎么用?C# Canvas.GetInnerCanvas使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Canvas
的用法示例。
在下文中一共展示了Canvas.GetInnerCanvas方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Canvas_GetInnerCanvasException
public void Test_Canvas_GetInnerCanvasException()
{
Canvas canvas = new Canvas(new Resolution(10, 8));
#region Filling canvas
for (int y = 0; y < 8; y++)
for (int x = 0; x < 10; x++)
{
if (x == 5 && y == 2) canvas.SetColor(x, y, Color.Red);
else canvas.SetColor(x, y, Color.Black);
}
#endregion
Canvas actual = canvas.GetInnerCanvas(5, 2, new Resolution(10, 4));
}
示例2: Test_Canvas_GetInnerCanvas
public void Test_Canvas_GetInnerCanvas()
{
Canvas canvas = new Canvas(new Resolution(10, 8));
#region Filling canvas
for(int y = 0; y < 8; y++)
for (int x = 0; x < 10; x++)
{
if (x == 5 && y == 2) canvas.SetColor(x, y, Color.Red);
else canvas.SetColor(x, y, Color.Black);
}
#endregion
Canvas expectedCanvas = new Canvas(new Resolution(3, 4));
#region Filling canvas
for (int y = 0; y < 4; y++)
for (int x = 0; x < 3; x++)
{
if (x == 0 && y == 0) expectedCanvas.SetColor(x, y, Color.Red);
else expectedCanvas.SetColor(x, y, Color.Black);
}
#endregion
Canvas actual = canvas.GetInnerCanvas(5, 2, new Resolution(3, 4));
Assert.IsTrue(actual.Width == expectedCanvas.Width && actual.Height == expectedCanvas.Height);
for (int y = 0; y < actual.Height; y++)
for (int x = 0; x < actual.Width; x++)
Assert.IsTrue(actual.GetColor(x, y) == expectedCanvas.GetColor(x, y));
}