The existing code has a bug since it sets the top of the rectangle to y1. This implies y1 < y2. However, the height is calculated as y1 - y2 (which would be negative).
There is a one character fix (i.e., set height = y2 - y1), but, the provided patch is more robust to misunderstandings by the user about what order the coordinates are provided in.
The existing code has a bug since it sets the top of the rectangle to y1. This implies y1 < y2. However, the height is calculated as y1 - y2 (which would be negative).
There is a one character fix (i.e., set height = y2 - y1), but, the provided patch is more robust to misunderstandings by the user about what order the coordinates are provided in.