Duality.Resources.Texture.AdjustSize C# (CSharp) Method

AdjustSize() protected method

Processes the specified size based on the Textures SizeMode.
protected AdjustSize ( float width, float height ) : void
width float
height float
return void
        protected void AdjustSize(float width, float height)
        {
            this.size = new Vector2(MathF.Abs(width), MathF.Abs(height));
            this.pxWidth = MathF.RoundToInt(this.size.X);
            this.pxHeight = MathF.RoundToInt(this.size.Y);
            this.pxDiameter = MathF.Distance(this.pxWidth, this.pxHeight);

            if (this.texSizeMode == SizeMode.NonPowerOfTwo)
            {
                this.texWidth = this.pxWidth;
                this.texHeight = this.pxHeight;
                this.uvRatio = Vector2.One;
            }
            else
            {
                this.texWidth = MathF.NextPowerOfTwo(this.pxWidth);
                this.texHeight = MathF.NextPowerOfTwo(this.pxHeight);
                if (this.pxWidth != this.texWidth || this.pxHeight != this.texHeight)
                {
                    if (this.texSizeMode == SizeMode.Enlarge)
                    {
                        this.uvRatio.X = (float)this.pxWidth / (float)this.texWidth;
                        this.uvRatio.Y = (float)this.pxHeight / (float)this.texHeight;
                    }
                    else
                        this.uvRatio = Vector2.One;
                }
                else
                    this.uvRatio = Vector2.One;
            }
        }