From 614f9998dec8ff585db030b5d2e9933e65c3e6ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 22 Feb 2011 10:35:48 +0100 Subject: [PATCH] More optimisations in Path#getBounds(). --- src/path/Path.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/path/Path.js b/src/path/Path.js index b6e55863..65375aae 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -81,6 +81,7 @@ Path = PathItem.extend({ if (b == 0) continue; var t = -c / b; + // Test for good root and add to bounds if good (same below) if (0 < t && t < 1) add(null, t); continue; @@ -89,11 +90,12 @@ Path = PathItem.extend({ var b2ac = b * b - 4 * a * c; if (b2ac < 0) continue; - var sqrt = Math.sqrt(b2ac), f = 1 / (a * -2); - var t1 = (b - sqrt) * f; + var sqrt = Math.sqrt(b2ac), + f = 1 / (a * -2), + t1 = (b - sqrt) * f, + t2 = (b + sqrt) * f; if (0 < t1 && t1 < 1) add(null, t1); - var t2 = (b + sqrt) * f; if (0 < t2 && t2 < 1) add(null, t2); }