Ejemplo 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;
        }
Ejemplo n.º 2
0
        private void DrawRight(SpriteBatch batch, Texture2D texture, Color color, RectangleF rectangle, float drawDepth = 0)
        {
            float xpos = rectangle.x + rectangle.width - distRight;

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

                Rectangle drawRect = new Rectangle(new Vector2(xpos, rectangle.y + distTop + (EdgeRight.height * (int)num)).ToPoint(),
                                                   new Vector2(distRight, over * EdgeRight.height).ToPoint());
                batch.Draw(texture, drawRect, EdgeRight.ToRectangle(), color, 0, Vector2.Zero, SpriteEffects.None, drawDepth);
            }
        }