@@ -2453,13 +2453,30 @@ Corner Shaping</h3>
24532453
24542454 The [=margin edge=] , being outside the [=border edge=] ,
24552455 calculates its radius by <em> adding</em> the corresponding margin thickness
2456- to each border radius.
2457- However, in order to create a sharper corner when the border radius is small
2458- (and thus ensure continuity between round and sharp corners),
2459- when the [=border radius=] is less than the margin,
2460- the margin is multiplied by the proportion 1 + (<var> r</var> -1)<sup> 3</sup> ,
2461- where <var> r</var> is the ratio of the border radius to the margin,
2462- in calculating the corner radii of the margin box shape.
2456+ to each border radius, with the corresponding [=outset-adjusted border radius=] applied.
2457+
2458+ <div algorithm="border-radius-outset">
2459+
2460+ When expanding an [=edge=] that has a [=border radius=] , e.g. for computing the [=margin edge=] , 'box-shadow' spread, or 'overflow-clip-margin' ,
2461+ the different [=border radius=] values are adjusted so that a small rounded corner with a big outset does not appear to be disproportionally round.
2462+
2463+ This is done by computing the corresponding [=outset-adjusted border radius=] .
2464+
2465+ To compute the <dfn export>outset-adjusted border radius</dfn> given the 2-dimensional [=size=] s |edge|, |radius|, and |outset|:
2466+ 1. Let |coverage| be <code> 2 * min(|radius|'s [=width=] / |edge|' s [=width=] , |radius|'s [=height=] / |edge|' s [=height=] )</code> .
2467+ 1. Let |adustedRadiusWidth| be the [=adjusted radius dimension=] given |coverage|, |radius|'s [=width=], and |outset|' s [=width=] .
2468+ 1. Let |adustedRadiusHeight| be the [=adjusted radius dimension=] given |coverage|, |radius|'s [=height=], and |outset|' s [=height=] .
2469+ 1. Return (|adustedRadiusWidth|, |adustedRadiusHeight|).
2470+
2471+ To compute the <dfn>adjusted radius dimension</dfn> given numbers |coverage|, |radius|, and |outset|:
2472+ 1. If |radius| is greater than |spread|, or if |coverage| is greater than 1, then return <code> |radius| + |outset|</code> .
2473+ 1. Let |ratio| be <code> |radius| / |outset|</code> .
2474+ 1. Return <code> |radius| + |outset| * (1 - (1 - |ratio|)<sup> 3</sup> * (1 - |coverage|<sup> 3</sup> ))</code> .
2475+
2476+ Note: this algorithm is designed to reduce the effect of the |outset| (or spread) on the shape of the corner.
2477+ The |coverage| factor makes this reduction more pronounced for rectangular shapes (where the [=border-radius=] is close to 0),
2478+ and less pronounced for elliptical shapes (where the [=border-radius=] is close to 50%).
2479+ </div>
24632480
24642481
24652482<h3 id="corner-clipping">
@@ -3544,19 +3561,8 @@ Shadow Shape, Spread, and Knockout</h4>
35443561 the corner radii of the shadow are also increased (decreased, for inner shadows)
35453562 from the border-box (padding-box) radii by adding (subtracting)
35463563 the [=spread distance=] (and flooring at zero).
3547- However, in order to create a sharper corner when the border radius is small
3548- (and thus ensure continuity between round and sharp corners),
3549- when the [=border radius=] is less than the [=spread distance=]
3550- (or in the case of an inner shadow,
3551- less than the absolute value of a negative [=spread distance=] ),
3552- the [=spread distance=]
3553- is first multiplied by the proportion 1 + (<var> r</var> -1)<sup> 3</sup> ,
3554- where <var> r</var> is the ratio of the border radius to the [=spread distance=] ,
3555- in calculating the corner radii of the spread shadow shape.
3556- For example, if the border radius is 10px and the [=spread distance=] is 20px (<var> r</var> = .5),
3557- the corner radius of the shadow shape will be 10px + 20px × (1 + (.5 - 1)<sup> 3</sup> ) = 27.5px
3558- rather than 30px.
3559- This adjustment is applied independently to the radii in each dimension.
3564+ For outer shadows, the [=border-radius=] is then [=outset-adjusted border radius|adjusted=] , independently in each dimension,
3565+ to preseve the sharpness of rounded corners.
35603566
35613567 The 'border-image' does not affect the shape of the box-shadow.
35623568
0 commit comments