Esempio n. 1
0
        public void GetTextures(Texture2D texture)
        {
            this.texture = texture;
            if (!hasTextures)
            {
                TexTopLeft  = GetTexturePart(texture, CornerTopLeft.ToRectangle(), "topleft");
                TexTopRight = GetTexturePart(texture, CornerTopRight.ToRectangle(), "topright");
                TexBotLeft  = GetTexturePart(texture, CornerBottomLeft.ToRectangle(), "botleft");
                TexBotRight = GetTexturePart(texture, CornerBottomRight.ToRectangle(), "botright");

                TexTop    = GetTexturePart(texture, EdgeTop.ToRectangle(), "top");
                TexLeft   = GetTexturePart(texture, EdgeLeft.ToRectangle(), "left");
                TexRight  = GetTexturePart(texture, EdgeRight.ToRectangle(), "right");
                TexBottom = GetTexturePart(texture, EdgeBottom.ToRectangle(), "bottom");

                TexCenter = GetTexturePart(texture, Center.ToRectangle(), "center");
            }

            hasTextures = true;
        }
Esempio n. 2
0
        private void DrawBottom(SpriteBatch batch, Texture2D texture, Color color, RectangleF rectangle, float drawDepth = 0)
        {
            float ypos = rectangle.y + (rectangle.height - distBottom);

            if (drawMode == DrawMode.Stretch)
            {
                batch.Draw(texture, new RectangleF(rectangle.x + distLeft, ypos, (rectangle.width - (distLeft + distRight)), distBottom).ToRectangle(),
                           EdgeBottom.ToRectangle(), color, 0, Vector2.Zero, SpriteEffects.None, drawDepth);
            }
            else
            {
                float num  = (rectangle.width - (distLeft + distRight)) / EdgeBottom.width;                //number of times to tile the texture
                float over = num % 1;
                for (int i = 0; i < (int)num; i++)
                {
                    float xpos = EdgeBottom.width * i;
                    batch.Draw(texture, new Vector2(rectangle.x + distLeft + xpos, ypos).ToPoint().ToVector2(), EdgeBottom.ToRectangle(), color, 0, Vector2.Zero, 1, SpriteEffects.None, drawDepth);
                }

                Rectangle drawRect = new Rectangle(new Vector2(rectangle.x + distLeft + (EdgeBottom.width * (int)num), ypos).ToPoint(),
                                                   new Vector2(over * EdgeBottom.width, distBottom).ToPoint());
                batch.Draw(texture, drawRect, EdgeBottom.ToRectangle(), color, 0, Vector2.Zero, SpriteEffects.None, drawDepth);
            }
        }