@@ -1907,36 +1907,83 @@ Color Stop “Fixup”</h4>
1907
1907
1D Image Values: the ''stripes()'' notation {#stripes}
1908
1908
======================================================
1909
1909
1910
- The ''stripes()'' function allows to define a number of stripes of
1911
- different colors with different widths.
1912
-
1913
- The syntax for ''1d-image'' and ''stripes()'' is defined as:
1910
+ While most <<image>> values represent a 2-dimensional image,
1911
+ and <<color>> can be thought of as a "0-dimensional" image
1912
+ (unvarying in either axis),
1913
+ there are some contexts where a 1-dimensional image makes sense,
1914
+ specifying colors along a <dfn export>paint line</dfn>
1915
+ without defining a <em> direction</em> for the line.
1916
+ The <<1d-image>> type represents such images.
1917
+
1918
+ Some contexts will define how they use the <<1d-image>> as a 1-dimensional value;
1919
+ for example, in 'border-color' ,
1920
+ the given colors paint "outwards" from each side of the border.
1921
+ When used generically as an <<image>> , a <<1d-image>> is painted identically to a ''linear-gradient(to bottom, ...)''
1922
+ using the [=paint line=] as its [=gradient line=] .
1914
1923
1915
1924
<pre class=prod>
1916
1925
<dfn><1d-image></dfn> = <<stripes()>>
1917
1926
<dfn>stripes()</dfn> = stripes( [ <<color>> && [ <<length-percentage>> | <<flex>> ]? ]# )
1918
1927
</pre>
1919
-
1920
- The function represents a 1-dimensional image generated by a list of colors
1921
- and an optional thickness for each of them.
1922
-
1923
- A <<percentage>> or <<flex>> value refers to the total length of the image
1924
- in the used context.
1925
- The <<percentage>> must be between ''0%'' and ''100%'' inclusive;
1926
- any other value is invalid.
1927
-
1928
- If the thickness of a stripe is omitted, it is interpreted as ''1fr'' .
1929
-
1930
- If not defined differently by the context the function is used in, the
1931
- stripes are painted from top to bottom and tiled horizontally. If the size
1932
- of the painting area exceeds the total thickness of the stripes, the
1933
- remaining area is painted transparently. I.e. it behaves as if there was an
1934
- additional last ''transparent'' stripe. If the size of the painting area
1935
- is smaller than the total thickness of the stripes, the stripes are clipped
1936
- starting from the last defined color.
1937
-
1938
- The computed value of this function is the [=specified value=] with all
1939
- <<color>> s computed '1fr' values removed.
1928
+
1929
+ The ''stripes()'' function defines a 1d-image
1930
+ as a number of colored stripes with different widths.
1931
+
1932
+ Each comma-separated entry defines a solid-color stripe,
1933
+ each placed end-to-end on the [=paint line=] in the order given,
1934
+ with the specified <<color>> and thickness.
1935
+ If the thickness is omitted,
1936
+ it defaults to ''1fr'' .
1937
+
1938
+ In each entry, a <<percentage>> is relative to the |painting area|
1939
+ and must be between ''0%'' and ''100%'' inclusive
1940
+ or else the function is invalid.
1941
+ A <<flex>> is evaluated as a fraction of the |painting area|
1942
+ relative to the total sum of <<flex>> entries in the function,
1943
+ after subtracting the thickness of any non-<<flex>> entries
1944
+ (flooring the subtraction result at zero).
1945
+ If the sum of <<flex>> values is less than 1fr,
1946
+ the result of the subtraction is multiplied by the sum's value
1947
+ before being distributed.
1948
+
1949
+ <div class=example>
1950
+ For example,
1951
+ ''stripes(red 1fr, green 2fr, blue 100px)``
1952
+ with a |painting area| of '' 400px''
1953
+ will result in a 100px red stripe and 200px green stripe,
1954
+ giving red 1 share and green 2 shares of the 300px remaining
1955
+ after subtracting blue's 100px from the 400px total.
1956
+
1957
+ On the other hand,
1958
+ '' stripes(red .1fr, green .2fr, blue 100px)``
1959
+ with a |painting area| of ''400px''
1960
+ will instead give a 30px red stripe and 60px green stripe,
1961
+ followed by 100px of blue and then 210px of transparent.
1962
+ The 300px of leftover space is multiplied by .3,
1963
+ the value of the sum of the <<flex>> values,
1964
+ to obtain only 90px,
1965
+ which is then distributed in the 1:2 ratio
1966
+ the <<flex>> values would dictate.
1967
+
1968
+ (This is similar to how [=flex layout=] deals with small <<flex>> sums on a line,
1969
+ and ensures smoothly continuous behavior
1970
+ as the <<flex>> values approach zero.)
1971
+ </div>
1972
+
1973
+
1974
+ The |painting area| is defined by the context in which the ''stripes()'' function is used.
1975
+ If used generically as an <<image>> ,
1976
+ the |painting area| is the height of the [=concrete image size=] .
1977
+
1978
+ If the sum thickness of the stripes is smaller than the |painting area|,
1979
+ the [=paint line=] is [=transparent black=] for its remaining length,
1980
+ as if a final ''transparent'' argument were given.
1981
+ If the sum thickness is larger,
1982
+ any stripes or portions thereof that would be past the end of the [=paint line=] have no effect.
1983
+
1984
+ The computed value of this function is the [=specified value=]
1985
+ with all <<color>> s computed
1986
+ and all <<length-percentage>> s absolutized and computed to the extent possible.
1940
1987
1941
1988
<!--
1942
1989
██████ ████ ████████ ████ ██ ██ ██████
0 commit comments