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


C# Color.GetAt方法代码示例

本文整理汇总了C#中Color.GetAt方法的典型用法代码示例。如果您正苦于以下问题:C# Color.GetAt方法的具体用法?C# Color.GetAt怎么用?C# Color.GetAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Color的用法示例。


在下文中一共展示了Color.GetAt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PrintBoard

 private static void PrintBoard(Color[,] board)
 {
     int estimatedLength = (board.GetLength(0) * board.GetLength(1)) * 2;
     StringBuilder sb = new StringBuilder(estimatedLength);
     for (int y = 0; y < board.Height(); y++)
     {
         for (int x = 0; x < board.Width(); x++)
         {
             sb.Append((char) ColorToLetter(board.GetAt(x, y)));
             sb.Append(' ');
         }
         sb.AppendLine();
     }
     Console.WriteLine(sb);
 }
开发者ID:glenwatson,项目名称:Flood-It-Solver,代码行数:15,代码来源:StdOutDisplay.cs

示例2: EdgeCoverage

 private int EdgeCoverage(int x, int y, bool[,] continuousVisited, bool[,] edgesVisited, Color[,] board)
 {
     continuousVisited.SetAt(x, y, true);
     Color thisColor = board.GetAt(x, y);
     int result = 0;
     if (board.CanGetLeft(x) && !continuousVisited.GetLeftOf(x, y))
     {
         if (thisColor == board.GetLeftOf(x, y))
             result += EdgeCoverage(x - 1, y, continuousVisited, edgesVisited, board);
         else if (!edgesVisited.GetLeftOf(x, y))
         {
             edgesVisited.SetLeftOf(x, y, true);
             result++;
         }
     }
     if (board.CanGetAbove(y) && !continuousVisited.GetAboveOf(x, y))
     {
         if (thisColor == board.GetAboveOf(x, y))
             result += EdgeCoverage(x, y - 1, continuousVisited, edgesVisited, board);
         else if (!edgesVisited.GetAboveOf(x, y))
         {
             edgesVisited.SetAboveOf(x, y, true);
             result++;
         }
     }
     if (board.CanGetRight(x) && !continuousVisited.GetRightOf(x, y))
     {
         if (thisColor == board.GetRightOf(x, y))
             result += EdgeCoverage(x + 1, y, continuousVisited, edgesVisited, board);
         else if (!edgesVisited.GetRightOf(x, y))
         {
             edgesVisited.SetRightOf(x, y, true);
             result++;
         }
     }
     if (board.CanGetBelow(y) && !continuousVisited.GetBelowOf(x, y))
     {
         if (thisColor == board.GetBelowOf(x, y))
             result += EdgeCoverage(x, y + 1, continuousVisited, edgesVisited, board);
         else if (!edgesVisited.GetBelowOf(x, y))
         {
             edgesVisited.SetBelowOf(x, y, true);
             result++;
         }
     }
     return result;
 }
开发者ID:glenwatson,项目名称:Flood-It-Solver,代码行数:47,代码来源:IncreaseSurfaceAreaGridLogic.cs

示例3: BuildLookupGrid

        //private static TreeNode[,] ToTreeNode(MapNode[,] lookup)
        //{
        //    TreeNode[,] treeLookup = new TreeNode[lookup.Height(), lookup.Width()];
        //    for (int y = 0; y < lookup.Height(); y++)
        //    {
        //        for (int x = 0; x < lookup.Width(); x++)
        //        {
        //            TreeNode treeNode = new TreeNode(lookup.GetAt(x, y).Color);
        //            treeLookup.SetAt(x, y, treeNode);
        //            throw new NotImplementedException("Doesn't keep the same reference for touching colors");
        //        }
        //    }
        //    return treeLookup;
        //}
        private static MapNode[,] BuildLookupGrid(Color[,] board)
        {
            MapNode[,] lookup = new MapNode[board.Height(), board.Width()];

            //build lookup
            for (int y = 0; y < board.Height(); y++)
            {
                for (int x = 0; x < board.Width(); x++)
                {
                    //Create MapNode
                    bool isLeftSame = board.CanGetLeft(x) && board.GetAt(x, y) == board.GetLeftOf(x, y);
                    bool isAboveSame = board.CanGetAbove(y) && board.GetAt(x, y) == board.GetAboveOf(x, y);

                    if (isLeftSame && isAboveSame) //check above & to the left
                    {
                        MapNode left = lookup.GetLeftOf(x, y);
                        MapNode above = lookup.GetAboveOf(x, y);
                        lookup.SetAt(x, y, left);
                        if (left != above)
                        {
                            left.Merge(above);
                            //update "above's" references to left
                            for (int updateY = y; updateY >= 0; updateY--)
                            {
                                for (int updateX = x; updateX >= 0; updateX--)
                                {
                                    if (lookup.GetAt(updateX, updateY) == above)
                                        lookup.SetAt(updateX, updateY, left);
                                }
                            }
                        }
                    }
                    else if (isLeftSame) // check to the left
                    {
                        lookup.SetAt(x, y, lookup.GetLeftOf(x, y));
                    }
                    else if (isAboveSame) // check above
                    {
                        lookup.SetAt(x, y, lookup.GetAboveOf(x, y));
                    }
                    else
                    {
                        lookup.SetAt(x, y, new MapNode(board.GetAt(x, y)));
                    }
                }
            }
            return lookup;
        }
开发者ID:glenwatson,项目名称:Flood-It-Solver,代码行数:62,代码来源:MapBuilder.cs


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