Skip to content

Commit b7fc21a

Browse files
committed
[css-backgrounds] Add formula for continuous shift from sharp to rounded spread corners based on experimenting at TPAC with Bert, dbaron, plinss, and leaverou.
This not only results in continuous behavior, but gives better-looking results when the border radius is smaller than the spread radius. Special thanks to dbaron for suggesting we create such a formula, to leaverou for creating an experimentation framework and doggedly searching for better formulas, and to plinss for the suggestion to try the cubic. See spread-radius.html
1 parent bb91c19 commit b7fc21a

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

css-backgrounds/Overview.src.html

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2941,13 +2941,13 @@ <h3 id="the-box-shadow">Drop Shadows: the 'box-shadow' property</h3>
29412941

29422942
<p>If a spread distance is defined,
29432943
the shadow perimenter is expanded outward (for normal shadows) or contracted inward (for ''inset'' shadows)
2944-
by the spread distance in the direction normal to the original shadow perimeter.
2945-
Alternatively, the UA may approximate the transformed shadow perimeter shape by
2946-
outsetting (insetting, for inner shadows) the shadow's straight edges by the spread distance
2944+
by outsetting (insetting, for inner shadows) the shadow's straight edges by the spread distance
29472945
and increasing (decreasing, for inner shadows) and flooring at zero
29482946
the corner radii by the same amount.
2949-
For corners with a zero border-radius, however, the corner must remain
2950-
sharp&#8212;the operation is equivalent to scaling the shadow shape.
2947+
In order to create a sharper corner when the border radius is small,
2948+
when the ratio <var>r</var> of the border-radius to the spread distance is less than one,
2949+
the spread distance is multiplied by the proportion 1 + (<var>r</var>-1)<sup>3</sup>
2950+
when calculating the corner radii of the spread shadow shape.
29512951
In any case, the effective width and height of the shadowed shape
29522952
is floored at zero.
29532953
(A zero-sized shadowed shape would cause an outer shadow to disappear,
@@ -3302,12 +3302,16 @@ <h3 id="changes-2012-07">
33023302
<a href="http://www.w3.org/TR/2012/CR-css3-background-20120724/">24 July 2012 Candidate Recommendation</a>:
33033303

33043304
<ul>
3305-
<li>Allow <var>&lt;color></var> and ''inset'' to be interleaved in any order in 'box-shadow',
3306-
since they are not ambiguous and CSS generally allows variant ordering where not ambiguous.
33073305
<li>Allow <var>&lt;'background-clip'></var> and <var>&lt;'background-origin'></var>
33083306
to be separated by other component values in the 'background' shorthand,
33093307
since this is what is implemented.
3310-
<li>Clarify the definition of the spread for 'box-shadow'.
3308+
<li>Allow <var>&lt;color></var> and ''inset'' to be interleaved in any order in 'box-shadow',
3309+
since they are not ambiguous and CSS generally allows variant ordering where not ambiguous.
3310+
<li>Define gradually increasing corner radius formula for 'box-shadow' spread curvature
3311+
to create continuity between sharp corners ('border-radius' = 0)
3312+
and curved corners ('border-radius' > <var>spread distance</var>).
3313+
This also gives better results for all intermediate states.
3314+
<li>Tighten up the definition of spread for 'box-shadow'.
33113315
<li>Clarify that a 'border-style' of ''none'' also implies an initial 'border-image-width' of zero
33123316
(since 'border-image-width' is initially set to the computed 'border-width', which in this case is zero).
33133317
</ul>

0 commit comments

Comments
 (0)