diff options
Diffstat (limited to 'source/blender/blenlib/intern/rct.c')
-rw-r--r-- | source/blender/blenlib/intern/rct.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index 7fce9ac7e8d..5466acdba9f 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -142,6 +142,27 @@ void BLI_translate_rctf(rctf *rect, float x, float y) rect->ymax += y; } +/* change width & height around the central location */ +void BLI_resize_rcti(rcti *rect, int x, int y) +{ + rect->xmin= rect->xmax= (rect->xmax + rect->xmin) / 2; + rect->ymin= rect->ymax= (rect->ymax + rect->ymin) / 2; + rect->xmin -= x / 2; + rect->ymin -= y / 2; + rect->xmax= rect->xmin + x; + rect->ymax= rect->ymin + y; +} + +void BLI_resize_rctf(rctf *rect, float x, float y) +{ + rect->xmin= rect->xmax= (rect->xmax + rect->xmin) * 0.5f; + rect->ymin= rect->ymax= (rect->ymax + rect->ymin) * 0.5f; + rect->xmin -= x * 0.5f; + rect->ymin -= y * 0.5f; + rect->xmax= rect->xmin + x; + rect->ymax= rect->ymin + y; +} + int BLI_isect_rctf(rctf *src1, rctf *src2, rctf *dest) { float xmin, xmax; |