From 19e1178b16fd27882c7834d66ad6597847e6baff Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 25 Sep 2016 05:54:08 +0100 Subject: Space rotates hints (to make hidden hints visible). It is common for link-hint markers to be close togother, and overlapping. Here, `` rotates hint markers such that hidden markers become visible. For filtered hints we additionally require a modifier (because `` on its own is already a token separator). The calculation of overlapping hints is quite expensive: O(n^2) in the best case and O(n^3) in the worst cast. The worst case is extraordinarily unlikely to arise in practice. --- lib/rect.coffee | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/rect.coffee') diff --git a/lib/rect.coffee b/lib/rect.coffee index 0c67d287..d4807cc2 100644 --- a/lib/rect.coffee +++ b/lib/rect.coffee @@ -82,5 +82,14 @@ Rect = @create (Math.max rect1.left, rect2.left), (Math.max rect1.top, rect2.top), (Math.min rect1.right, rect2.right), (Math.min rect1.bottom, rect2.bottom) + # Determine whether two rects overlap. + rectsOverlap: do -> + halfOverlapChecker = (rect1, rect2) -> + (rect1.left <= rect2.left <= rect1.right or rect1.left <= rect2.right <= rect1.right) and + (rect1.top <= rect2.top <= rect1.bottom or rect1.top <= rect2.bottom <= rect1.bottom) + + (rect1, rect2) -> + halfOverlapChecker(rect1, rect2) or halfOverlapChecker rect2, rect1 + root = exports ? window root.Rect = Rect -- cgit v1.2.3