Ejemplo n.º 1
0
        /// <summary>
        /// Draws the surface background.
        /// </summary>
        protected virtual void DrawBackground()
        {
            var background = Style.Background;

            if (background && background.ResidentMipLevels > 0)
            {
                var   bSize = background.Size;
                float bw    = bSize.X;
                float bh    = bSize.Y;
                var   pos   = Float2.Mod(bSize);

                if (pos.X > 0)
                {
                    pos.X -= bw;
                }
                if (pos.Y > 0)
                {
                    pos.Y -= bh;
                }

                int maxI = Mathf.CeilToInt(Width / bw + 1.0f);
                int maxJ = Mathf.CeilToInt(Height / bh + 1.0f);

                for (int i = 0; i < maxI; i++)
                {
                    for (int j = 0; j < maxJ; j++)
                    {
                        Render2D.DrawTexture(background, new Rectangle(pos.X + i * bw, pos.Y + j * bh, bw, bh), Color.White);
                    }
                }
            }
        }