Skip to content

Commit 3bdd61e

Browse files
committed
fix draw_rectangle_lines bug, add draw_rectangle_lines_fixed, deprecate draw_rectangle_lines
1 parent 6a61986 commit 3bdd61e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/shapes.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,26 @@ pub fn draw_rectangle(x: f32, y: f32, w: f32, h: f32, color: Color) {
5050

5151
/// Draws a rectangle outline with its top-left corner at `[x, y]` with size `[w, h]` (width going to
5252
/// the right, height going down), with a given line `thickness` and `color`.
53+
///
54+
/// # Deprecation
55+
/// Due to a bug, this function does not actually draw lines that are `thickness` thick, but only `thickness / 2.`.
56+
/// To preserve backwards compability, this function was not changed, and
57+
/// a new function `draw_rectangle_lines_fixed` was added, which does not contain the bug.
58+
///
59+
/// See https://github.com/not-fl3/macroquad/issues/704 for more details.
60+
#[deprecated(
61+
since = "0.4.12",
62+
note = "incorrect thickness handling, see issue #704. use `draw_rectangle_lines_fixed`"
63+
)]
5364
pub fn draw_rectangle_lines(x: f32, y: f32, w: f32, h: f32, thickness: f32, color: Color) {
65+
draw_rectangle_lines_fixed(x, y, w, h, thickness / 2., color);
66+
}
67+
68+
/// Draws a rectangle outline with its top-left corner at `[x, y]` with size `[w, h]` (width going to
69+
/// the right, height going down), with a given line `thickness` and `color`.
70+
pub fn draw_rectangle_lines_fixed(x: f32, y: f32, w: f32, h: f32, thickness: f32, color: Color) {
5471
let context = get_context();
55-
let t = thickness / 2.;
72+
let t = thickness;
5673

5774
#[rustfmt::skip]
5875
let vertices = [

0 commit comments

Comments
 (0)