@@ -628,13 +628,30 @@ Corners</h2>
628628
629629 The [=margin edge=] , being outside the [=border edge=] ,
630630 calculates its radius by <em> adding</em> the corresponding margin thickness
631- to each border radius.
632- However, in order to create a sharper corner when the border radius is small
633- (and thus ensure continuity between round and sharp corners),
634- when the [=border radius=] is less than the margin,
635- the margin is multiplied by the proportion 1 + (<var> r</var> -1)<sup> 3</sup> ,
636- where <var> r</var> is the ratio of the border radius to the margin,
637- in calculating the corner radii of the margin box shape.
631+ to each border radius, with the corresponding [=outset-adjusted border radius=] applied.
632+
633+ <div algorithm="border-radius-outset">
634+
635+ When expanding an [=edge=] that has a [=border radius=] , e.g. for computing the [=margin edge=] , 'box-shadow' spread, or 'overflow-clip-margin' ,
636+ the different [=border radius=] values are adjusted so that a small rounded corner with a big outset does not appear to be disproportionally round.
637+
638+ This is done by computing the corresponding [=outset-adjusted border radius=] .
639+
640+ To compute the <dfn export>outset-adjusted border radius</dfn> given the 2-dimensional [=size=] s |edge|, |radius|, and |outset|:
641+ 1. Let |coverage| be <code> 2 * min(|radius|'s [=width=] / |edge|' s [=width=] , |radius|'s [=height=] / |edge|' s [=height=] )</code> .
642+ 1. Let |adustedRadiusWidth| be the [=adjusted radius dimension=] given |coverage|, |radius|'s [=width=], and |outset|' s [=width=] .
643+ 1. Let |adustedRadiusHeight| be the [=adjusted radius dimension=] given |coverage|, |radius|'s [=height=], and |outset|' s [=height=] .
644+ 1. Return (|adustedRadiusWidth|, |adustedRadiusHeight|).
645+
646+ To compute the <dfn>adjusted radius dimension</dfn> given numbers |coverage|, |radius|, and |outset|:
647+ 1. If |radius| is greater than |spread|, or if |coverage| is greater than 1, then return <code> |radius| + |outset|</code> .
648+ 1. Let |ratio| be <code> |radius| / |outset|</code> .
649+ 1. Return <code> |radius| + |outset| * (1 - (1 - |ratio|)<sup> 3</sup> * (1 - |coverage|<sup> 3</sup> ))</code> .
650+
651+ Note: this algorithm is designed to reduce the effect of the |outset| (or spread) on the shape of the corner.
652+ The |coverage| factor makes this reduction more pronounced for rectangular shapes (where the [=border-radius=] is close to 0),
653+ and less pronounced for elliptical shapes (where the [=border-radius=] is close to 50%).
654+ </div>
638655
639656
640657<h3 id="corner-clipping">
@@ -2969,19 +2986,8 @@ Shadow Shape, Spread, and Knockout</h4>
29692986 the corner radii of the shadow are also increased (decreased, for inner shadows)
29702987 from the border-box (padding-box) radii by adding (subtracting)
29712988 the [=spread distance=] (and flooring at zero).
2972- However, in order to create a sharper corner when the border radius is small
2973- (and thus ensure continuity between round and sharp corners),
2974- when the [=border radius=] is less than the [=spread distance=]
2975- (or in the case of an inner shadow,
2976- less than the absolute value of a negative [=spread distance=] ),
2977- the [=spread distance=]
2978- is first multiplied by the proportion 1 + (<var> r</var> -1)<sup> 3</sup> ,
2979- where <var> r</var> is the ratio of the border radius to the [=spread distance=] ,
2980- in calculating the corner radii of the spread shadow shape.
2981- For example, if the border radius is 10px and the [=spread distance=] is 20px (<var> r</var> = .5),
2982- the corner radius of the shadow shape will be 10px + 20px × (1 + (.5 - 1)<sup> 3</sup> ) = 27.5px
2983- rather than 30px.
2984- This adjustment is applied independently to the radii in each dimension.
2989+ For outer shadows, the [=border-radius=] is then [=outset-adjusted border radius|adjusted=] , independently in each dimension,
2990+ to preserve the sharpness of rounded corners.
29852991
29862992 The 'border-image' does not affect the shape of the box-shadow.
29872993
0 commit comments