コード例 #1
0
        /// <summary>
        /// Splits a rect into a series of columns.
        /// </summary>
        public static Rect[] Columns(this HUMMath.Data.SplitInto into, int count)
        {
            var averageHeight = (into.split.rect.height / count);
            var list          = new List <Rect>();

            for (int i = 0; i < count; i++)
            {
                Rect output = new Rect(
                    into.split.rect.x,
                    into.split.rect.y + (averageHeight * i),
                    into.split.rect.width,
                    averageHeight
                    );

                list.Add(output);
            }

            return(list.ToArray());
        }
コード例 #2
0
        /// <summary>
        /// Splits a rect into a multidimensional arrary of individual rects.
        /// </summary>
        public static Rect[,] Grid(this HUMMath.Data.SplitInto into, int columns, int rows)
        {
            var averageHeight = (into.split.rect.height / rows);
            var averageWidth  = (into.split.rect.width / columns);

            Rect[,] rects = (Rect[, ])Array.CreateInstance(typeof(Rect), columns, rows);

            for (int x = 0; x < columns; x++)
            {
                for (int y = 0; y < rows; y++)
                {
                    var rect = new Rect(
                        into.split.rect.x + (averageWidth * x),
                        into.split.rect.y + (averageHeight * y),
                        averageWidth,
                        averageHeight
                        );

                    rects[x, y] = rect;
                }
            }

            return(rects);
        }