当前位置: 首页>>代码示例>>C#>>正文


C# Canvas.SetCanvas方法代码示例

本文整理汇总了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);
        }
开发者ID:nsvova,项目名称:Embroidery-NS-Vova,代码行数:22,代码来源:UnitCanvas.cs

示例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);
                }
        }
开发者ID:nsvova,项目名称:Embroidery-NS-Vova,代码行数:43,代码来源:UnitCanvas.cs


注:本文中的Canvas.SetCanvas方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。