Skip to content

Commit d802a6c

Browse files
authored
[css-images-4] Described how to interpolate between fr units and lengths or percentages (w3c#9767)
1 parent 0c0127c commit d802a6c

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

css-images-4/Overview.bs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2919,25 +2919,14 @@ Interpolating ''stripes()'' {#interpolating-stripes}
29192919
Similar to gradients,
29202920
two ''stripes()'' can be interpolated,
29212921
allowing for smooth animations from one image to another.
2922-
There are only a few restrictions on what ''stripes()'' are allowed to be interpolated:
2923-
2924-
1. Both the starting and ending image must have the same number of <<color-stripe>>s.
2925-
2926-
2. Each pair of interpolated thicknesses must be of the same type,
2927-
i.e. both must either be of type <<length-percentage>>, or <<flex>>.
2928-
2929-
If the two images satisfy both constraints,
2922+
There is only one restriction on what ''stripes()'' are allowed to be interpolated.
2923+
Both the starting and ending image must have the same number of <<color-stripe>>s.
2924+
If the two images satisfy this constraint,
29302925
they must be interpolated as described below.
2931-
If they fail the second one only,
2932-
they must be abruptly transitioned at 50%
2933-
(unless otherwise specified by a future specification).
2934-
If they fail the first constraint,
2926+
If they fail the constraint,
29352927
they must be interpolated using ''cross-fade()''
29362928
as for generic images.
29372929

2938-
Note: The abrupt transition at 50% is so that content will not rely on cross-fading,
2939-
and smarter interpolation rules can be added for this case in the future.
2940-
29412930
1. Interpolate each component and stripe of the images independently.
29422931

29432932
2. To interpolate a stripe,
@@ -2946,6 +2935,13 @@ Interpolating ''stripes()'' {#interpolating-stripes}
29462935
Then, for each pair of stripes,
29472936
interpolate the thickness
29482937
and color independently.
2938+
<<flex>> values are interpolated as <<length-percentage>>s using the following formula:
2939+
2940+
<pre>max(0, 100% - sum-of-percents - sum-of-fixed) * flex value / max(1, sum-of-flexes)</pre>
2941+
2942+
where ''sum-of-percents'' is the sum of all <<percentage>>s in the ''stripes()'' function,
2943+
''sum-of-fixed'' is the sum of all fixed <<length>>s in the function,
2944+
and ''sum-of-flexes'' is the sum of all <<flex>> values.
29492945

29502946
<!--
29512947
██████ ████████ ████████ ████ ███ ██ ████ ████████ ███ ████████ ████ ███████ ██ ██

0 commit comments

Comments
 (0)