Fix 6e90b828c6: Off-by-one in Rect::CentreTo. (#14643)
* Rect right/bottom are inclusive so -1 must be taken from width/height. * Misnamed variable, `new_right` is actually `new_top`.
This commit is contained in:
@@ -261,8 +261,8 @@ struct Rect {
|
|||||||
[[nodiscard]] inline Rect CentreTo(int width, int height) const
|
[[nodiscard]] inline Rect CentreTo(int width, int height) const
|
||||||
{
|
{
|
||||||
int new_left = CentreBounds(this->left, this->right, width);
|
int new_left = CentreBounds(this->left, this->right, width);
|
||||||
int new_right = CentreBounds(this->top, this->bottom, height);
|
int new_top = CentreBounds(this->top, this->bottom, height);
|
||||||
return {new_left, new_right, new_left + width, new_right + height};
|
return {new_left, new_top, new_left + width - 1, new_top + height - 1};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user