Skip to content

Commit

Permalink
Expose blurSigma (flutter#3743)
Browse files Browse the repository at this point in the history
  • Loading branch information
abarth committed May 5, 2016
1 parent 6a46bf2 commit 2fbf11a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/flutter/lib/src/painting/box_painter.dart
Expand Up @@ -395,9 +395,13 @@ class BoxShadow {

final double spreadRadius;

/// The [blurRadius] in sigmas instead of logical pixels.
///
/// See the sigma argument to [MaskFilter.blur].
///
// See SkBlurMask::ConvertRadiusToSigma().
// https://github.com/google/skia/blob/bb5b77db51d2e149ee66db284903572a5aac09be/src/effects/SkBlurMask.cpp#L23
double get _blurSigma => blurRadius * 0.57735 + 0.5;
// <https://github.com/google/skia/blob/bb5b77db51d2e149ee66db284903572a5aac09be/src/effects/SkBlurMask.cpp#L23>
double get blurSigma => blurRadius * 0.57735 + 0.5;

/// Returns a new box shadow with its offset, blurRadius, and spreadRadius scaled by the given factor.
BoxShadow scale(double factor) {
Expand Down Expand Up @@ -1291,7 +1295,7 @@ class _BoxDecorationPainter extends BoxPainter {
for (BoxShadow boxShadow in _decoration.boxShadow) {
final Paint paint = new Paint()
..color = boxShadow.color
..maskFilter = new MaskFilter.blur(BlurStyle.normal, boxShadow._blurSigma);
..maskFilter = new MaskFilter.blur(BlurStyle.normal, boxShadow.blurSigma);
final Rect bounds = rect.shift(boxShadow.offset).inflate(boxShadow.spreadRadius);
_paintBox(canvas, bounds, paint);
}
Expand Down

0 comments on commit 2fbf11a

Please sign in to comment.