From 9cce2d864554cb78abfb5e2909dfb1a506933d3c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 12 Aug 2012 01:07:31 +0000 Subject: smooth-view for 2d views, graph editor, sequencer, node view, works with border zoom, view selected, view all. --- source/blender/blenlib/BLI_rect.h | 4 ++++ source/blender/blenlib/intern/rct.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h index 1c06e107c1f..55ab961cc53 100644 --- a/source/blender/blenlib/BLI_rect.h +++ b/source/blender/blenlib/BLI_rect.h @@ -53,6 +53,10 @@ void BLI_rctf_translate(struct rctf *rect, float x, float y); void BLI_rcti_translate(struct rcti *rect, int x, int y); void BLI_rcti_resize(struct rcti *rect, int x, int y); void BLI_rctf_resize(struct rctf *rect, float x, float y); +void BLI_rctf_interp(struct rctf *rect, const struct rctf *rect_a, const struct rctf *rect_b, const float fac); +//void BLI_rcti_interp(struct rctf *rect, struct rctf *rect_a, struct rctf *rect_b, float fac); +int BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, const float limit); +int BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b); int BLI_in_rcti(const struct rcti *rect, const int x, const int y); int BLI_in_rcti_v(const struct rcti *rect, const int xy[2]); int BLI_in_rctf(const struct rctf *rect, const float x, const float y); diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index 68a00d81444..e22becddfd6 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -270,6 +270,39 @@ void BLI_rctf_resize(rctf *rect, float x, float y) rect->ymax = rect->ymin + y; } +void BLI_rctf_interp(rctf *rect, const rctf *rect_a, const rctf *rect_b, const float fac) +{ + const float ifac = 1.0f - fac; + rect->xmin = (rect_a->xmin * ifac) + (rect_b->xmin * fac); + rect->xmax = (rect_a->xmax * ifac) + (rect_b->xmax * fac); + rect->ymin = (rect_a->ymin * ifac) + (rect_b->ymin * fac); + rect->ymax = (rect_a->ymax * ifac) + (rect_b->ymax * fac); +} + +/* BLI_rcti_interp() not needed yet */ + +int BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, const float limit) +{ + if (fabsf(rect_a->xmin - rect_b->xmin) < limit) + if (fabsf(rect_a->xmax - rect_b->xmax) < limit) + if (fabsf(rect_a->ymin - rect_b->ymin) < limit) + if (fabsf(rect_a->ymax - rect_b->ymax) < limit) + return 1; + + return 0; +} + +int BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b) +{ + if (rect_a->xmin == rect_b->xmin) + if (rect_a->xmax == rect_b->xmax) + if (rect_a->ymin == rect_b->ymin) + if (rect_a->ymax == rect_b->ymax) + return 1; + + return 0; +} + int BLI_rctf_isect(const rctf *src1, const rctf *src2, rctf *dest) { float xmin, xmax; -- cgit v1.2.3