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