/// <summary> /// /// </summary> /// <param name="image"></param> /// <param name="stretchArea">rectangle defining the center area in percentage (0-100)</param> public StretchableImage(Texture2D image, Rectangle stretchArea) { _stretchableArea = stretchArea; Rectangle imgBounds = new Rectangle(0, 0, image.Width, image.Height); _rect = initalSplitRect(imgBounds, stretchArea); _image = splitImage(_rect, image); }
private SplitedImage splitImage(SplitedRect rect, Texture2D image) { SplitedImage splitedImg = new SplitedImage(); splitedImg._topLeft = Utils.CreatePartImage(rect.topLeftR, image, MyGame.SpriteBatch.GraphicsDevice); splitedImg._topRight = Utils.CreatePartImage(rect.topRightR, image, MyGame.SpriteBatch.GraphicsDevice); splitedImg._topCenter = Utils.CreatePartImage(rect.topCenterR, image, MyGame.SpriteBatch.GraphicsDevice); splitedImg._left = Utils.CreatePartImage(rect.leftR, image, MyGame.SpriteBatch.GraphicsDevice); splitedImg._right = Utils.CreatePartImage(rect.rightR, image, MyGame.SpriteBatch.GraphicsDevice); splitedImg._bottomLeft = Utils.CreatePartImage(rect.bottomLeftR, image, MyGame.SpriteBatch.GraphicsDevice); splitedImg._bottomRight = Utils.CreatePartImage(rect.bottomRightR, image, MyGame.SpriteBatch.GraphicsDevice); splitedImg._bottomCenter = Utils.CreatePartImage(rect.bottomCenterR, image, MyGame.SpriteBatch.GraphicsDevice); splitedImg._center = Utils.CreatePartImage(rect.centerR, image, MyGame.SpriteBatch.GraphicsDevice); return(splitedImg); }
private SplitedImage splitImage(SplitedRect rect, Texture2D image) { SplitedImage splitedImg = new SplitedImage(); splitedImg._topLeft = Utils.CreatePartImage(rect.topLeftR, image, MyGame.SpriteBatch.GraphicsDevice); splitedImg._topRight = Utils.CreatePartImage(rect.topRightR, image, MyGame.SpriteBatch.GraphicsDevice); splitedImg._topCenter = Utils.CreatePartImage(rect.topCenterR, image, MyGame.SpriteBatch.GraphicsDevice); splitedImg._left = Utils.CreatePartImage(rect.leftR, image, MyGame.SpriteBatch.GraphicsDevice); splitedImg._right = Utils.CreatePartImage(rect.rightR, image, MyGame.SpriteBatch.GraphicsDevice); splitedImg._bottomLeft = Utils.CreatePartImage(rect.bottomLeftR, image, MyGame.SpriteBatch.GraphicsDevice); splitedImg._bottomRight = Utils.CreatePartImage(rect.bottomRightR, image, MyGame.SpriteBatch.GraphicsDevice); splitedImg._bottomCenter = Utils.CreatePartImage(rect.bottomCenterR, image, MyGame.SpriteBatch.GraphicsDevice); splitedImg._center = Utils.CreatePartImage(rect.centerR, image, MyGame.SpriteBatch.GraphicsDevice); return splitedImg; }