コード例 #1
0
ファイル: GridUtils.cs プロジェクト: yfdtc12345/Football
        public static Grid2 <float> ImageToGreyScaleGrid(Texture2D texture, int xOffset, int yOffset)
        {
            var dimensions    = new GridPoint2(texture.width, texture.height);
            var storageRect   = new GridRect(GridPoint2.Zero, dimensions);
            var implicitShape = ImplicitShape.Parallelogram(dimensions);
            var explicitShape = implicitShape.ToExplicit(storageRect);

            var grid        = new Grid2 <float>(explicitShape);
            var textureData = texture.GetPixels().Select(c => c.grayscale).ToArray();

            grid.Fill(p => textureData[(p.X + xOffset) % texture.width + (texture.width * ((p.Y + yOffset) % texture.height))]);

            return(grid);
        }
コード例 #2
0
ファイル: ExplicitShape.cs プロジェクト: Radeg/dots_all-modes
            public BitmaskShape2(string[] shape)
            {
                int max    = shape.Max(row => row.Length);
                var bounds = new GridRect(GridPoint2.Zero, new GridPoint2(max, shape.Length));

                grid = new Grid2 <bool>(bounds);

                foreach (var point in grid.Points)
                {
                    if (point.X < shape[point.Y].Length)
                    {
                        grid[point] = shape[point.Y][point.X] != '0';
                    }
                    else
                    {
                        grid[point] = false;
                    }
                }
            }