/// <summary>
        /// Gets the information needed to draw this image onto a area.
        /// </summary>
        /// <returns>The steps necessary to draw this image with origin (0, 0)</returns>
        public IEnumerable <(TextureSlice source, TextureSlice destination)> DrawingPrimitives(TextureSlice area)
        {
            var borderThickness = CalculateBorder(area.Size);

            // Top Left
            yield return(
                TextureSlice.FromTwoPoints(
                    (0, 0),
                    topLeft
                    ),
                new TextureSlice(
                    0,
                    0,
                    borderThickness,
                    borderThickness
                    ) + area.TopLeft
                );

            // Top Center
            yield return(
                TextureSlice.FromTwoPoints(
                    (topLeft.X, 0),
                    (topRight.X, topRight.Y)
                    ),
                new TextureSlice(
                    borderThickness,
                    0,
                    squeezeCenterWidth(area.Width, borderThickness),
                    borderThickness
                    ) + area.TopLeft
                );

            // Top Right
            yield return(
                TextureSlice.FromTwoPoints(
                    (topRight.X, 0),
                    (Texture.Width, topRight.Y)
                    ),
                new TextureSlice(
                    area.Width - borderThickness,
                    0,
                    borderThickness,
                    borderThickness
                    ) + area.TopLeft
                );

            // Center Left
            yield return(
                TextureSlice.FromTwoPoints(
                    (0, topLeft.Y),
                    bottomLeft
                    ),
                new TextureSlice(
                    0,
                    borderThickness,
                    borderThickness,
                    squeezeCenterHeight(area.Height, borderThickness)
                    ) + area.TopLeft
                );

            // Center
            yield return(
                TextureSlice.FromTwoPoints(
                    topLeft,
                    bottomRight
                    ),
                new TextureSlice(
                    borderThickness,
                    borderThickness,
                    squeezeCenterWidth(area.Width, borderThickness),
                    squeezeCenterHeight(area.Height, borderThickness)
                    ) + area.TopLeft
                );

            // Center Right
            yield return(
                TextureSlice.FromTwoPoints(
                    topRight,
                    (Texture.Width, bottomRight.Y)
                    ),
                new TextureSlice(
                    area.Width - borderThickness,
                    borderThickness,
                    borderThickness,
                    squeezeCenterHeight(area.Height, borderThickness)
                    ) + area.TopLeft
                );

            // Bottom Left
            yield return(
                TextureSlice.FromTwoPoints(
                    (0, bottomLeft.Y),
                    (bottomLeft.X, Texture.Height)
                    ),
                new TextureSlice(
                    0,
                    area.Height - borderThickness,
                    borderThickness,
                    borderThickness
                    ) + area.TopLeft
                );

            // Bottom Center
            yield return(
                TextureSlice.FromTwoPoints(
                    (bottomLeft.X, bottomLeft.Y),
                    (bottomRight.X, Texture.Height)
                    ),
                new TextureSlice(
                    borderThickness,
                    area.Height - borderThickness,
                    squeezeCenterWidth(area.Width, borderThickness),
                    borderThickness
                    ) + area.TopLeft
                );

            // Bottom Center
            yield return(
                TextureSlice.FromTwoPoints(
                    bottomRight,
                    (Texture.Width, Texture.Height)
                    ),
                new TextureSlice(
                    area.Width - borderThickness,
                    area.Height - borderThickness,
                    borderThickness,
                    borderThickness
                    ) + area.TopLeft
                );
        }
예제 #2
0
        /// <summary>
        /// Gets the information needed to draw this image onto a area.
        /// </summary>
        /// <returns>The steps necessary to draw this image with origin (0, 0)</returns>
        public IEnumerable <(TextureSlice source, TextureSlice destination)> DrawingPrimitives(TextureSlice area)
        {
            var borderThickness = this.CalculateBorder(area.Size);

            // Left border
            yield return(
                TextureSlice.FromTwoPoints(
                    (0, 0),
                    (left, Texture.Height)
                    ),
                new TextureSlice(
                    0,
                    0,
                    borderThickness,
                    area.Height
                    ) + area.TopLeft
                );

            // Center (stretching part)
            yield return(
                TextureSlice.FromTwoPoints(
                    (left, 0),
                    (right, Texture.Height)
                    ),
                new TextureSlice(
                    borderThickness,
                    0,
                    area.Width - 2 * borderThickness,
                    area.Height
                    ) + area.TopLeft
                );

            // Right border
            yield return(
                TextureSlice.FromTwoPoints(
                    (right, 0),
                    (Texture.Width, Texture.Height)
                    ),
                new TextureSlice(
                    area.Width - borderThickness,
                    0,
                    borderThickness,
                    area.Height
                    ) + area.TopLeft
                );
        }