Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix draw_rectangle_lines bug, add draw_rectangle_lines_fixed #761

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,26 @@ pub fn draw_rectangle(x: f32, y: f32, w: f32, h: f32, color: Color) {

/// Draws a rectangle outline with its top-left corner at `[x, y]` with size `[w, h]` (width going to
/// the right, height going down), with a given line `thickness` and `color`.
///
/// # Deprecation
/// Due to a bug, this function does not actually draw lines that are `thickness` thick, but only `thickness / 2.`.
/// To preserve backwards compability, this function was not changed, and
/// a new function `draw_rectangle_lines_fixed` was added, which does not contain the bug.
///
/// See https://github.com/not-fl3/macroquad/issues/704 for more details.
#[deprecated(
since = "0.4.12",
note = "incorrect thickness handling, see issue #704. use `draw_rectangle_lines_fixed`"
)]
pub fn draw_rectangle_lines(x: f32, y: f32, w: f32, h: f32, thickness: f32, color: Color) {
draw_rectangle_lines_fixed(x, y, w, h, thickness / 2., color);
}

/// Draws a rectangle outline with its top-left corner at `[x, y]` with size `[w, h]` (width going to
/// the right, height going down), with a given line `thickness` and `color`.
pub fn draw_rectangle_lines_fixed(x: f32, y: f32, w: f32, h: f32, thickness: f32, color: Color) {
let context = get_context();
let t = thickness / 2.;
let t = thickness;

#[rustfmt::skip]
let vertices = [
Expand Down
Loading