瀏覽代碼

Fix `ImageDrawRectangleRec` (#3721)

Le Juez Victor 1 年之前
父節點
當前提交
746f129bfe
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/rtextures.c

+ 2 - 2
src/rtextures.c

@@ -3562,8 +3562,8 @@ void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color)
     if ((dst->data == NULL) || (dst->width == 0) || (dst->height == 0)) return;
     if ((dst->data == NULL) || (dst->width == 0) || (dst->height == 0)) return;
 
 
     // Security check to avoid drawing out of bounds in case of bad user data
     // Security check to avoid drawing out of bounds in case of bad user data
-    if (rec.x < 0) { rec.width -= rec.x; rec.x = 0; }
-    if (rec.y < 0) { rec.height -= rec.y; rec.y = 0; }
+    if (rec.x < 0) { rec.width += rec.x; rec.x = 0; }
+    if (rec.y < 0) { rec.height += rec.y; rec.y = 0; }
     if (rec.width < 0) rec.width = 0;
     if (rec.width < 0) rec.width = 0;
     if (rec.height < 0) rec.height = 0;
     if (rec.height < 0) rec.height = 0;