使用小于零的 Vector2 缩放图像

Scaling an image with a Vector2 less than zero

我目前正在做一个项目,我正在尝试缩小图像。 我有一个由以下代码确定的 Hitbox。

public Rectangle bound
    {
        get
        {
            return new Rectangle((int)position.X, (int)position.Y, 
                texture.Width * (int)scale.X,
                texture.Height * (int)scale.Y);
        }
    }

这在假设比例为一或更大的情况下有效。但是,当我输入小于一次碰撞的比例值时,Console.WriteLine() 函数 returns {X:300 Y:300 Width:0 Height:0 }. 我做错了什么吗?

嗯,我不觉得很傻。

public Rectangle bound
    {
        get
        {
            return texture == null ? new Rectangle(0,0,0,0) : new Rectangle((int)position.X, (int)position.Y,
                (int)(texture.Width * scale.X), (int)(texture.Height * scale.Y));
        }
    }

显然,如果您的矩形尺寸是浮点数,则它 returns 为零。