From: Tab Atkins Jr. <jackalmage@gmail.com>

Date: Thu, 15 Jul 2010 14:08:40 -0700

Message-ID: <AANLkTikoxjV7b291qJo3koYLkJ_WO1UYzd_JbqEHQQwz@mail.gmail.com>

To: Brad Kemper <brad.kemper@gmail.com>

Cc: "L. David Baron" <dbaron@dbaron.org>, Aryeh Gregor <Simetrical+w3c@gmail.com>, Simon Fraser <smfr@me.com>, Brendan Kenny <bckenny@gmail.com>, www-style list <www-style@w3.org>

Date: Thu, 15 Jul 2010 14:08:40 -0700

Message-ID: <AANLkTikoxjV7b291qJo3koYLkJ_WO1UYzd_JbqEHQQwz@mail.gmail.com>

To: Brad Kemper <brad.kemper@gmail.com>

Cc: "L. David Baron" <dbaron@dbaron.org>, Aryeh Gregor <Simetrical+w3c@gmail.com>, Simon Fraser <smfr@me.com>, Brendan Kenny <bckenny@gmail.com>, www-style list <www-style@w3.org>

On Wed, Jul 14, 2010 at 5:30 PM, Brad Kemper <brad.kemper@gmail.com> wrote: > On Jul 14, 2010, at 5:17 PM, "Tab Atkins Jr." <jackalmage@gmail.com> wrote: > >> If we can get everyone to agree that we want to require a gaussian >> blur, then I'm more than happy to provide the exact equation you can >> plug the blur length into to get a stdev to hand to the gaussian blur >> function. I don't think everyone will agree to that, though. > > If you could do that as an example of how to achieve the required results, then maybe we could all be relatively happy. Welp, as it turns out you can't invert the gaussian blur function with elementary functions. Doing it right requires the use of the Lambert W function, which must be solved numerically for most cases. The exact answer is given by: stdev = sqrt( -x^2 / W( -2 * pi * G^2 * x^2 )) Where X is the blur distance (distance from the edge, so half the total area affected by the blur) and G is the fraction you're trying to hit (.01 for 99% transparency). W() then has to be approximated numerically using Newton's method or similar. It's still somewhat expensive, as it involves a couple of exponentials (though, they're all the same, so I guess it can be computed once, in which case it turns into ordinary +-*/ math). Given an appropriate guess, which is easy to get, I suspect you could iterate just once or twice to get a usable approximation. Alternately, we could just ensure that the allowed range was narrow enough to look the same for "reasonable" shadows, but wide enough for cheap-and-dirty approximations to safely nestle into it. Allowing the 99% point to come within +- 2% of the specified length should ensure that shadows with a blur of less than 10px or so to be guaranteed to be the same size (modulo rounding), and I suspect allows enough room for a cheap approximation to be usable. ~TJReceived on Thursday, 15 July 2010 21:09:34 GMT

*
This archive was generated by hypermail 2.3.1
: Tuesday, 26 March 2013 17:20:29 GMT
*