Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-03-09 08:48:09 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-03-09 08:48:09 +0400
commit6a4567b9ab957ef912129f24aa4d3f60c3363c4f (patch)
tree1fc722e77a39f22b1dc5aa1634716bbcebfc03b2 /source/blender/blenlib/intern/rct.c
parentbcb99b794d7176cf94cb87c483a0efa458b12ef7 (diff)
BLI Rect: utility function to transform a point using 2 rect's
Diffstat (limited to 'source/blender/blenlib/intern/rct.c')
-rw-r--r--source/blender/blenlib/intern/rct.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index 51bd9eee0a6..61e5783cd3e 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -347,6 +347,16 @@ void BLI_rctf_do_minmax_v(rctf *rect, const float xy[2])
if (xy[1] > rect->ymax) rect->ymax = xy[1];
}
+/* given 2 rectangles - transform a point from one to another */
+void BLI_rctf_transform_pt_v(const rctf *dst, const rctf *src, float xy_dst[2], const float xy_src[2])
+{
+ xy_dst[0] = ((xy_src[0] - src->xmin) / (src->xmax - src->xmin));
+ xy_dst[0] = dst->xmin + ((dst->xmax - dst->xmin) * xy_dst[0]);
+
+ xy_dst[1] = ((xy_src[1] - src->ymin) / (src->ymax - src->ymin));
+ xy_dst[1] = dst->ymin + ((dst->ymax - dst->ymin) * xy_dst[1]);
+}
+
void BLI_rcti_translate(rcti *rect, int x, int y)
{
rect->xmin += x;