Exemple #1
0
        public static SpriteElement DrawSpriteBox(Texture2D texture, Vector4 destination, BoxSpriteBounds spriteBounds, float edgeScale)
        {
            var allVerts = new List <VertVT>();

            float[] BoxSizeX = new float[]
            {
                (spriteBounds.GetColumnSize(0) / spriteBounds.Width) * edgeScale,
                0,
                (spriteBounds.GetColumnSize(2) / spriteBounds.Width) * edgeScale
            };
            BoxSizeX[1] = destination.Z - BoxSizeX[0] - BoxSizeX[2];

            float[] BoxSizeY = new float[]
            {
                (spriteBounds.GetRowSize(0) / spriteBounds.Height) * edgeScale,
                0,
                (spriteBounds.GetRowSize(2) / spriteBounds.Height) * edgeScale
            };
            BoxSizeY[1] = destination.W - BoxSizeY[0] - BoxSizeY[2];

            float[] BoxPosX = new float[] {
                destination.X,
                destination.X + BoxSizeX[0],
                destination.X + BoxSizeX[0] + BoxSizeX[1]
            };
            float[] BoxPosY = new float[] {
                destination.Y,
                destination.Y + BoxSizeY[0],
                destination.Y + BoxSizeY[0] + BoxSizeY[1]
            };

            for (int y = 0; y < 3; y++)
            {
                for (int x = 0; x < 3; x++)
                {
                    var boxSpriteBounds = spriteBounds.GetRegionBounds(x, y);
                    if (boxSpriteBounds.Width > 0 && boxSpriteBounds.Height > 0)
                    {
                        var boxVerts = GetElementVertices(
                            new Vector4(BoxPosX[x], BoxPosY[y], BoxSizeX[x], BoxSizeY[y]), boxSpriteBounds);
                        allVerts.AddRange(boxVerts);
                    }
                }
            }
            var sprite = new SpriteElement()
            {
                Texture   = texture,
                Offset    = VertexList.Count,
                ElemCount = allVerts.Count
            };

            SpritesToRender.Add(sprite);
            VertexList.AddRange(allVerts);

            return(sprite);
        }
Exemple #2
0
        public static SpriteElement DrawSpriteBox(Texture2D texture, Vector4 destination, BoxSpriteBounds spriteBounds)
        {
            float scale = Math.Min(destination.Z, destination.W);

            return(DrawSpriteBox(texture, destination, spriteBounds, scale));
        }