BLI_rect: add a float version of the 'pad' function

This commit is contained in:
Campbell Barton 2020-11-17 23:47:44 +11:00
parent 1e1c39fc89
commit 7785a9c9d2
2 changed files with 9 additions and 0 deletions

View File

@ -65,6 +65,7 @@ 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_pad(struct rctf *rect, float pad_x, float 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);

View File

@ -651,6 +651,14 @@ void BLI_rcti_pad(rcti *rect, int pad_x, int pad_y)
rect->ymax += pad_y;
}
void BLI_rctf_pad(rctf *rect, float pad_x, float pad_y)
{
rect->xmin -= pad_x;
rect->ymin -= pad_y;
rect->xmax += pad_x;
rect->ymax += pad_y;
}
void BLI_rctf_resize_x(rctf *rect, float x)
{
rect->xmin = BLI_rctf_cent_x(rect) - (x * 0.5f);