FlatRedBall.Graphics.Texture.ImageData.RotateClockwise90 C# (CSharp) Method

RotateClockwise90() public method

public RotateClockwise90 ( ) : void
return void
        public void RotateClockwise90()
        {
            Color[] newData = new Color[width * height];

            int newWidth = height;
            int newHeight = width;

            int xToPullFrom;
            int yToPullFrom;

            for (int x = 0; x < newWidth; x++)
            {
                for (int y = 0; y < newHeight; y++)
                {
                    xToPullFrom = newHeight - 1 - y;
                    yToPullFrom = x;

                    newData[y * newWidth + x] =
                        mData[yToPullFrom * width + xToPullFrom];
                }
            }

            width = newWidth;
            height = newHeight;
            mData = newData;
        }