[Bf-blender-cvs] [66800a1deb2] blender-v2.91-release: BLI_rect: add resize_x/y functions

Campbell Barton noreply at git.blender.org
Tue Oct 27 04:13:07 CET 2020


Commit: 66800a1deb2dc9e6cd13690a5246fbbea45c16b0
Author: Campbell Barton
Date:   Tue Oct 27 13:50:51 2020 +1100
Branches: blender-v2.91-release
https://developer.blender.org/rB66800a1deb2dc9e6cd13690a5246fbbea45c16b0

BLI_rect: add resize_x/y functions

Without this, it's inconvenient to resize a single axis
and doesn't read very well.

===================================================================

M	source/blender/blenlib/BLI_rect.h
M	source/blender/blenlib/intern/rct.c

===================================================================

diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h
index 1d15a10ebc0..1d742e2c28a 100644
--- a/source/blender/blenlib/BLI_rect.h
+++ b/source/blender/blenlib/BLI_rect.h
@@ -62,8 +62,12 @@ void BLI_rcti_translate(struct rcti *rect, int x, int y);
 void BLI_rcti_recenter(struct rcti *rect, int x, int y);
 void BLI_rctf_recenter(struct rctf *rect, float x, float y);
 void BLI_rcti_resize(struct rcti *rect, int x, int y);
+void BLI_rcti_resize_x(struct rcti *rect, int x);
+void BLI_rcti_resize_y(struct rcti *rect, int y);
 void BLI_rcti_pad(struct rcti *rect, int pad_x, int pad_y);
 void BLI_rctf_resize(struct rctf *rect, float x, float y);
+void BLI_rctf_resize_x(struct rctf *rect, float x);
+void BLI_rctf_resize_y(struct rctf *rect, float y);
 void BLI_rcti_scale(rcti *rect, const float scale);
 void BLI_rctf_scale(rctf *rect, const float scale);
 void BLI_rctf_pad_y(struct rctf *rect,
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index f952b62cb61..bec5f0ab3ba 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -623,6 +623,18 @@ void BLI_rctf_recenter(rctf *rect, float x, float y)
 }
 
 /* change width & height around the central location */
+void BLI_rcti_resize_x(rcti *rect, int x)
+{
+  rect->xmin = BLI_rcti_cent_x(rect) - (x / 2);
+  rect->xmax = rect->xmin + x;
+}
+
+void BLI_rcti_resize_y(rcti *rect, int y)
+{
+  rect->ymin = BLI_rcti_cent_y(rect) - (y / 2);
+  rect->ymax = rect->ymin + y;
+}
+
 void BLI_rcti_resize(rcti *rect, int x, int y)
 {
   rect->xmin = BLI_rcti_cent_x(rect) - (x / 2);
@@ -639,6 +651,18 @@ void BLI_rcti_pad(rcti *rect, int pad_x, int pad_y)
   rect->ymax += pad_y;
 }
 
+void BLI_rctf_resize_x(rctf *rect, float x)
+{
+  rect->xmin = BLI_rctf_cent_x(rect) - (x * 0.5f);
+  rect->xmax = rect->xmin + x;
+}
+
+void BLI_rctf_resize_y(rctf *rect, float y)
+{
+  rect->ymin = BLI_rctf_cent_y(rect) - (y * 0.5f);
+  rect->ymax = rect->ymin + y;
+}
+
 void BLI_rctf_resize(rctf *rect, float x, float y)
 {
   rect->xmin = BLI_rctf_cent_x(rect) - (x * 0.5f);



More information about the Bf-blender-cvs mailing list